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/secrets.properties
|
||||||
|
|
||||||
walkguide-backend/demo/hs_err_pid*.log
|
walkguide-backend/demo/hs_err_pid*.log
|
||||||
|
walkguide-backend/demo/backend-run*.log
|
||||||
walkguide-backend/demo/src/main/resources/firebase/*.json
|
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
|
walkguide-mobile/walkguide_app/ios/Runner/GoogleService-Info.plist
|
||||||
|
|
||||||
# Android SDK path (generated by Android Studio)
|
# 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
|
### 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:
|
Both dev and production expect these values from environment variables or `secrets.properties`:
|
||||||
|
|
||||||
```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:
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
DB_URL
|
DB_URL
|
||||||
@ -447,12 +441,12 @@ Swagger UI:
|
|||||||
http://localhost:8080/swagger-ui.html
|
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
|
```powershell
|
||||||
$env:DB_URL="jdbc:postgresql://202.46.28.160:2002/uas_5803024001"
|
$env:DB_URL="jdbc:postgresql://<host>:<port>/<database>"
|
||||||
$env:DB_USERNAME="5803024001"
|
$env:DB_USERNAME="<database_username>"
|
||||||
$env:DB_PASSWORD="pw5803024001"
|
$env:DB_PASSWORD="<database_password>"
|
||||||
$env:JWT_SECRET="your-base64-secret"
|
$env:JWT_SECRET="your-base64-secret"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -46,16 +46,14 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
|||||||
class "VoiceCommandHandler\n<<Facade>>" as VoiceCommandHandler {
|
class "VoiceCommandHandler\n<<Facade>>" as VoiceCommandHandler {
|
||||||
- _ttsService : TtsService
|
- _ttsService : TtsService
|
||||||
- _sttService : SttService
|
- _sttService : SttService
|
||||||
- _router : GoRouter
|
- _router : CommandRouter
|
||||||
- _walkGuideBloc : WalkGuideBloc
|
- _actions : Map<VoiceCommandKey, CommandAction>
|
||||||
- _sosBloc : SosBloc
|
|
||||||
- _notifBloc : NotificationBloc
|
|
||||||
+ processText(String command) : void
|
+ processText(String command) : void
|
||||||
- _matchCommand(String) : VoiceCommandKey?
|
- _matchCommand(String) : VoiceCommandKey?
|
||||||
- _executeCommand(VoiceCommandKey) : void
|
- _executeCommand(VoiceCommandKey) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
class "WalkGuideBloc\n<<Client>>" as WalkGuideBlocFacade {
|
class "WalkGuideCubit\n<<Client>>" as WalkGuideCubitFacade {
|
||||||
+ onVoiceCommand(String text)
|
+ onVoiceCommand(String text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +67,8 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
|||||||
|
|
||||||
class "SttService " as SttServiceFacade <<Subsystem>>
|
class "SttService " as SttServiceFacade <<Subsystem>>
|
||||||
class "TtsService " as TtsServiceFacade <<Subsystem>>
|
class "TtsService " as TtsServiceFacade <<Subsystem>>
|
||||||
class "GoRouter\n<<Router>>" as GoRouterFacade <<Subsystem>>
|
class "CommandRouter\n<<Router Adapter>>" as GoRouterFacade <<Subsystem>>
|
||||||
class "SosBloc " as SosBlocFacade <<Subsystem>>
|
class "CommandAction\n<<Cubit Callback>>" as CommandActionFacade <<Subsystem>>
|
||||||
|
|
||||||
class "LocationService\n<<Service>>" as LocationService <<Subsystem>>
|
class "LocationService\n<<Service>>" as LocationService <<Subsystem>>
|
||||||
class "ActivityLogService\n<<Service>>" as ActivityService <<Subsystem>>
|
class "ActivityLogService\n<<Service>>" as ActivityService <<Subsystem>>
|
||||||
@ -82,11 +80,11 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
|||||||
' GET /api/v1/guardian/dashboard
|
' GET /api/v1/guardian/dashboard
|
||||||
}
|
}
|
||||||
|
|
||||||
WalkGuideBlocFacade --> VoiceCommandHandler : processText()
|
WalkGuideCubitFacade --> VoiceCommandHandler : processText()
|
||||||
VoiceCommandHandler --> SttServiceFacade : delegates
|
VoiceCommandHandler --> SttServiceFacade : delegates
|
||||||
VoiceCommandHandler --> TtsServiceFacade : delegates
|
VoiceCommandHandler --> TtsServiceFacade : delegates
|
||||||
VoiceCommandHandler --> GoRouterFacade : delegates
|
VoiceCommandHandler --> GoRouterFacade : delegates
|
||||||
VoiceCommandHandler --> SosBlocFacade : delegates
|
VoiceCommandHandler --> CommandActionFacade : delegates
|
||||||
|
|
||||||
GuardianDashboardController --> GuardianDashboardService : getDashboard()
|
GuardianDashboardController --> GuardianDashboardService : getDashboard()
|
||||||
GuardianDashboardService --> LocationService : aggregates
|
GuardianDashboardService --> LocationService : aggregates
|
||||||
|
|||||||
@ -57,8 +57,8 @@ package "④ Repository Pattern [Structural — Proxy]" #FFF3E0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class "WalkGuideRepositoryImpl\n<<Proxy>>" as WalkGuideRepoImpl {
|
class "WalkGuideRepositoryImpl\n<<Proxy>>" as WalkGuideRepoImpl {
|
||||||
- _remoteDataSource : WalkGuideRemoteDataSource
|
- _apiClient : ApiClient
|
||||||
- _localDataSource : WalkGuideLocalDataSource
|
- _offlineQueue : OfflineQueueService
|
||||||
- _connectivity : ConnectivityPlus
|
- _connectivity : ConnectivityPlus
|
||||||
+ startSession() : Either<Failure, void>
|
+ startSession() : Either<Failure, void>
|
||||||
+ logObstacle(req) : Either<Failure, void>
|
+ logObstacle(req) : Either<Failure, void>
|
||||||
@ -72,16 +72,16 @@ package "④ Repository Pattern [Structural — Proxy]" #FFF3E0 {
|
|||||||
+ syncPending() : Either<Failure, void>
|
+ syncPending() : Either<Failure, void>
|
||||||
}
|
}
|
||||||
|
|
||||||
class "WalkGuideRemoteDataSource\n<<Remote>>" as RemoteDSWalk {
|
class "ApiClient\n<<Remote>>" as RemoteDSWalk {
|
||||||
+ startSession() : void
|
+ startSession() : void
|
||||||
+ logObstacle(req) : void
|
+ logObstacle(req) : void
|
||||||
' POST /api/v1/user/obstacle
|
' POST /api/v1/user/obstacle
|
||||||
}
|
}
|
||||||
|
|
||||||
class "WalkGuideLocalDataSource\n<<SQLite/Drift>>" as LocalDSWalk {
|
class "OfflineQueueService + LocalDatabase\n<<SQLite Cache>>" as LocalDSWalk {
|
||||||
+ cacheObstacle(ObstacleLog) : void
|
+ cacheObstacle(ObstacleLog) : void
|
||||||
+ getPendingLogs() : List<ObstacleLog>
|
+ getPendingLogs() : List<ObstacleLog>
|
||||||
' Drift ORM — offline first
|
' SQLite-backed offline first
|
||||||
}
|
}
|
||||||
|
|
||||||
WalkGuideRepo <|.. WalkGuideRepoImpl : implements
|
WalkGuideRepo <|.. WalkGuideRepoImpl : implements
|
||||||
|
|||||||
@ -43,30 +43,27 @@ skinparam note {
|
|||||||
|
|
||||||
package "⑤ Observer Pattern [Behavioral]" #F3E5F5 {
|
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>
|
# stateController : StreamController<State>
|
||||||
+ {abstract} on<E>(EventHandler)
|
|
||||||
+ add(Event event)
|
|
||||||
+ emit(State state)
|
+ emit(State state)
|
||||||
+ stream : Stream<State>
|
+ stream : Stream<State>
|
||||||
}
|
}
|
||||||
|
|
||||||
class "WalkGuideBloc\n<<ConcreteSubject>>" as WalkGuideBlocObs {
|
class "WalkGuideCubit\n<<ConcreteSubject>>" as WalkGuideCubitObs {
|
||||||
+ on<StartWalkGuide>(_onStart)
|
+ start()
|
||||||
+ on<StopWalkGuide>(_onStop)
|
+ stop()
|
||||||
+ on<CameraFrameReceived>(_onFrame)
|
+ logObstacle()
|
||||||
+ on<ObstacleDetected>(_onObstacle)
|
|
||||||
- _yoloDetector : YoloDetector
|
- _yoloDetector : YoloDetector
|
||||||
- _ttsService : TtsService
|
- _ttsService : TtsService
|
||||||
- _hapticService : HapticService
|
- _hapticService : HapticService
|
||||||
}
|
}
|
||||||
|
|
||||||
class "BlocBuilder<WalkGuideBloc, WalkGuideState>\n<<Observer / Widget>>" as BlocBuilderWidget {
|
class "BlocBuilder<WalkGuideCubit, WalkGuideState>\n<<Observer / Widget>>" as BlocBuilderWidget {
|
||||||
+ builder(ctx, state) : Widget
|
+ builder(ctx, state) : Widget
|
||||||
' Rebuilds UI on every state emission
|
' 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
|
+ listener(ctx, state) : void
|
||||||
' Side effects: TTS, haptic, navigation
|
' Side effects: TTS, haptic, navigation
|
||||||
}
|
}
|
||||||
@ -84,9 +81,9 @@ package "⑤ Observer Pattern [Behavioral]" #F3E5F5 {
|
|||||||
' Updates flutter_map markers in real-time
|
' Updates flutter_map markers in real-time
|
||||||
}
|
}
|
||||||
|
|
||||||
BlocSubject <|-- WalkGuideBlocObs : extends
|
BlocSubject <|-- WalkGuideCubitObs : extends
|
||||||
WalkGuideBlocObs --> BlocBuilderWidget : emits state\n(rebuilds UI)
|
WalkGuideCubitObs --> BlocBuilderWidget : emits state\n(rebuilds UI)
|
||||||
WalkGuideBlocObs --> BlocListenerWidget : emits state\n(side effects)
|
WalkGuideCubitObs --> BlocListenerWidget : emits state\n(side effects)
|
||||||
WebSocketObs --> GuardianMapObs : notifies\nlive location
|
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 accuracy;
|
||||||
private Double speed;
|
private Double speed;
|
||||||
private Double heading;
|
private Double heading;
|
||||||
|
private Integer batteryLevel;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ -22,6 +23,8 @@ public class DashboardResponse {
|
|||||||
// Status
|
// Status
|
||||||
private long unreadSosCount;
|
private long unreadSosCount;
|
||||||
private long unreadNotifCount;
|
private long unreadNotifCount;
|
||||||
|
private long obstaclesToday;
|
||||||
|
private Map<String, Object> userStatus;
|
||||||
|
|
||||||
// Recent activity (5 terbaru)
|
// Recent activity (5 terbaru)
|
||||||
private List<ActivityLogResponse> recentActivity;
|
private List<ActivityLogResponse> recentActivity;
|
||||||
|
|||||||
@ -16,5 +16,6 @@ public class LocationResponse {
|
|||||||
private Double accuracy;
|
private Double accuracy;
|
||||||
private Double speed;
|
private Double speed;
|
||||||
private Double heading;
|
private Double heading;
|
||||||
|
private Integer batteryLevel;
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,9 @@ public class LocationHistory {
|
|||||||
private Double speed; // m/s
|
private Double speed; // m/s
|
||||||
private Double heading; // derajat 0-360
|
private Double heading; // derajat 0-360
|
||||||
|
|
||||||
|
@Column(name = "battery_level")
|
||||||
|
private Integer batteryLevel;
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false, updatable = false)
|
@Column(name = "created_at", nullable = false, updatable = false)
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,13 @@ public class GlobalExceptionHandler {
|
|||||||
}
|
}
|
||||||
@ExceptionHandler(RuntimeException.class)
|
@ExceptionHandler(RuntimeException.class)
|
||||||
public ResponseEntity<ApiResponse<Object>> handleRuntime(RuntimeException ex) {
|
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)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.body(ApiResponse.error("INTERNAL_ERROR", ex.getMessage()));
|
.body(ApiResponse.error("INTERNAL_ERROR", message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
|
|||||||
@ -4,7 +4,11 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ObstacleLogRepository extends JpaRepository<ObstacleLog, Long> {
|
public interface ObstacleLogRepository extends JpaRepository<ObstacleLog, Long> {
|
||||||
Page<ObstacleLog> findByUserIdOrderByCreatedAtDesc(Long userId, Pageable pageable);
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -82,7 +85,34 @@ public class JwtUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Key getSignInKey() {
|
private Key getSignInKey() {
|
||||||
byte[] keyBytes = Decoders.BASE64.decode(secretKey);
|
byte[] keyBytes = decodeSecret(secretKey);
|
||||||
return Keys.hmacShaKeyFor(keyBytes);
|
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.data.domain.PageRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GuardianDashboardService {
|
public class GuardianDashboardService {
|
||||||
@ -17,6 +22,7 @@ public class GuardianDashboardService {
|
|||||||
private final ActivityLogService activityLogService;
|
private final ActivityLogService activityLogService;
|
||||||
private final SosEventRepository sosEventRepository;
|
private final SosEventRepository sosEventRepository;
|
||||||
private final GuardianNotificationRepository notifRepository;
|
private final GuardianNotificationRepository notifRepository;
|
||||||
|
private final ObstacleLogRepository obstacleLogRepository;
|
||||||
|
|
||||||
public DashboardResponse getDashboard(Long guardianId) {
|
public DashboardResponse getDashboard(Long guardianId) {
|
||||||
var pairing = pairingRelationRepository
|
var pairing = pairingRelationRepository
|
||||||
@ -40,6 +46,21 @@ public class GuardianDashboardService {
|
|||||||
long unreadSos = sosEventRepository.findByUserIdOrderByCreatedAtDesc(userId, PageRequest.of(0, 100))
|
long unreadSos = sosEventRepository.findByUserIdOrderByCreatedAtDesc(userId, PageRequest.of(0, 100))
|
||||||
.stream().filter(s -> s.getStatus().name().equals("TRIGGERED")).count();
|
.stream().filter(s -> s.getStatus().name().equals("TRIGGERED")).count();
|
||||||
long unreadNotif = notifRepository.countByUserIdAndIsReadFalse(userId);
|
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()
|
return DashboardResponse.builder()
|
||||||
.pairedUserId(userId)
|
.pairedUserId(userId)
|
||||||
@ -49,6 +70,8 @@ public class GuardianDashboardService {
|
|||||||
.lastLocation(lastLocation)
|
.lastLocation(lastLocation)
|
||||||
.unreadSosCount(unreadSos)
|
.unreadSosCount(unreadSos)
|
||||||
.unreadNotifCount(unreadNotif)
|
.unreadNotifCount(unreadNotif)
|
||||||
|
.obstaclesToday(obstaclesToday)
|
||||||
|
.userStatus(userStatus)
|
||||||
.recentActivity(recentActivity)
|
.recentActivity(recentActivity)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public class LocationService {
|
|||||||
.accuracy(req.getAccuracy())
|
.accuracy(req.getAccuracy())
|
||||||
.speed(req.getSpeed())
|
.speed(req.getSpeed())
|
||||||
.heading(req.getHeading())
|
.heading(req.getHeading())
|
||||||
|
.batteryLevel(req.getBatteryLevel())
|
||||||
.build();
|
.build();
|
||||||
loc = locationHistoryRepository.save(loc);
|
loc = locationHistoryRepository.save(loc);
|
||||||
|
|
||||||
@ -136,6 +137,7 @@ public class LocationService {
|
|||||||
return LocationResponse.builder()
|
return LocationResponse.builder()
|
||||||
.id(l.getId()).lat(l.getLat()).lng(l.getLng())
|
.id(l.getId()).lat(l.getLat()).lng(l.getLng())
|
||||||
.accuracy(l.getAccuracy()).speed(l.getSpeed()).heading(l.getHeading())
|
.accuracy(l.getAccuracy()).speed(l.getSpeed()).heading(l.getHeading())
|
||||||
|
.batteryLevel(l.getBatteryLevel())
|
||||||
.createdAt(l.getCreatedAt()).build();
|
.createdAt(l.getCreatedAt()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,35 +1,9 @@
|
|||||||
# ===================================================
|
DB_URL=jdbc:postgresql://<host>:<port>/<database>
|
||||||
# Profile: prod (production)
|
DB_USERNAME=<database_username>
|
||||||
# Aktifkan dengan: --spring.profiles.active=prod
|
DB_PASSWORD=<database_password>
|
||||||
# Semua nilai WAJIB diisi via environment variable
|
JWT_SECRET=<base64_hs256_secret_at_least_32_bytes>
|
||||||
# Tidak ada default value — akan gagal start jika kosong
|
JWT_EXPIRATION=86400000
|
||||||
# ===================================================
|
AGORA_APP_ID=<agora_app_id>
|
||||||
|
AGORA_APP_CERTIFICATE=<agora_app_certificate>
|
||||||
spring:
|
FIREBASE_CREDENTIALS_PATH=classpath:firebase/google-services-admin.json
|
||||||
datasource:
|
FIREBASE_NOTIFICATIONS_COLLECTION=notifications
|
||||||
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
|
|
||||||
|
|||||||
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: ${DB_URL:jdbc:postgresql://202.46.28.160:2002/uas_5803024001}
|
url: ${DB_URL}
|
||||||
username: ${DB_USERNAME:5803024001}
|
username: ${DB_USERNAME}
|
||||||
password: ${DB_PASSWORD:pw5803024001}
|
password: ${DB_PASSWORD}
|
||||||
hikari:
|
hikari:
|
||||||
maximum-pool-size: ${DB_POOL_MAX:1}
|
maximum-pool-size: ${DB_POOL_MAX:1}
|
||||||
minimum-idle: ${DB_POOL_MIN_IDLE:0}
|
minimum-idle: ${DB_POOL_MIN_IDLE:0}
|
||||||
@ -16,8 +16,8 @@ spring:
|
|||||||
idle-timeout: ${DB_IDLE_TIMEOUT:30000}
|
idle-timeout: ${DB_IDLE_TIMEOUT:30000}
|
||||||
max-lifetime: ${DB_MAX_LIFETIME:120000}
|
max-lifetime: ${DB_MAX_LIFETIME:120000}
|
||||||
|
|
||||||
flyway:
|
flyway:
|
||||||
enabled: ${FLYWAY_ENABLED:false}
|
enabled: ${FLYWAY_ENABLED:true}
|
||||||
|
|
||||||
jpa:
|
jpa:
|
||||||
show-sql: true
|
show-sql: true
|
||||||
@ -26,12 +26,12 @@ spring:
|
|||||||
format_sql: true
|
format_sql: true
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
secret: ${JWT_SECRET:d2Fsa2d1aWRlLWRldi1qd3Qtc2VjcmV0LWtleS0zMi1ieXRlcy1taW5pbXVt}
|
secret: ${JWT_SECRET}
|
||||||
expiration: ${JWT_EXPIRATION:86400000}
|
expiration: ${JWT_EXPIRATION:86400000}
|
||||||
|
|
||||||
agora:
|
agora:
|
||||||
app-id: ${AGORA_APP_ID:e36c2b6592e34cfda1f6ea6432a5e68d}
|
app-id: ${AGORA_APP_ID:}
|
||||||
app-certificate: ${AGORA_APP_CERTIFICATE:70a4288475734a8c92ff8686c66cbc77}
|
app-certificate: ${AGORA_APP_CERTIFICATE:}
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
# ===== SERVER =====
|
# ===== 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.port=${SERVER_PORT:8080}
|
||||||
server.address=${SERVER_ADDRESS:0.0.0.0}
|
server.address=${SERVER_ADDRESS:0.0.0.0}
|
||||||
|
|
||||||
# ===== POSTGRESQL CONNECTION =====
|
# ===== POSTGRESQL CONNECTION =====
|
||||||
spring.datasource.url=${DB_URL:jdbc:postgresql://202.46.28.160:2002/uas_5803024001}
|
spring.datasource.url=${DB_URL}
|
||||||
spring.datasource.username=${DB_USERNAME:5803024001}
|
spring.datasource.username=${DB_USERNAME}
|
||||||
spring.datasource.password=${DB_PASSWORD:pw5803024001}
|
spring.datasource.password=${DB_PASSWORD}
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
# ===== HIKARI POOL (keep DB classroom slots low) =====
|
# ===== HIKARI POOL (keep DB classroom slots low) =====
|
||||||
spring.datasource.hikari.maximum-pool-size=${DB_POOL_MAX:1}
|
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
|
spring.flyway.baseline-on-migrate=true
|
||||||
|
|
||||||
# ===== JWT =====
|
# ===== JWT =====
|
||||||
jwt.secret=${JWT_SECRET:d2Fsa2d1aWRlLWRldi1qd3Qtc2VjcmV0LWtleS0zMi1ieXRlcy1taW5pbXVt}
|
jwt.secret=${JWT_SECRET}
|
||||||
jwt.expiration=${JWT_EXPIRATION:86400000}
|
jwt.expiration=${JWT_EXPIRATION:86400000}
|
||||||
|
|
||||||
# ===== SWAGGER =====
|
# ===== SWAGGER =====
|
||||||
@ -35,7 +35,7 @@ springdoc.swagger-ui.path=/swagger-ui.html
|
|||||||
springdoc.api-docs.path=/v3/api-docs
|
springdoc.api-docs.path=/v3/api-docs
|
||||||
|
|
||||||
# ===== AGORA RTC =====
|
# ===== AGORA RTC =====
|
||||||
agora.app-id=${AGORA_APP_ID:e36c2b6592e34cfda1f6ea6432a5e68d}
|
agora.app-id=${AGORA_APP_ID:}
|
||||||
agora.app-certificate=${AGORA_APP_CERTIFICATE:}
|
agora.app-certificate=${AGORA_APP_CERTIFICATE:}
|
||||||
|
|
||||||
# ===== FIREBASE =====
|
# ===== 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.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<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_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
@ -13,7 +16,8 @@
|
|||||||
<application
|
<application
|
||||||
android:label="WalkGuide"
|
android:label="WalkGuide"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@ -34,6 +38,9 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.EnableImpeller"
|
||||||
|
android:value="false" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<queries>
|
<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/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
import 'app_cubit.dart';
|
import 'app_cubit.dart';
|
||||||
import 'router.dart';
|
import 'router.dart';
|
||||||
|
import '../core/i18n/app_strings.dart';
|
||||||
import '../core/theme/app_colors.dart';
|
import '../core/theme/app_colors.dart';
|
||||||
|
|
||||||
class WalkGuideApp extends StatelessWidget {
|
class WalkGuideApp extends StatelessWidget {
|
||||||
@ -15,126 +17,151 @@ class WalkGuideApp extends StatelessWidget {
|
|||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => AppCubit(),
|
create: (_) => AppCubit(),
|
||||||
child: MaterialApp.router(
|
child: BlocBuilder<AppCubit, AppState>(
|
||||||
title: 'WalkGuide',
|
builder: (context, state) => MaterialApp.router(
|
||||||
debugShowCheckedModeBanner: false,
|
title: 'WalkGuide',
|
||||||
routerConfig: appRouter,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
routerConfig: appRouter,
|
||||||
useMaterial3: true,
|
builder: (context, child) {
|
||||||
colorScheme: ColorScheme.fromSeed(
|
final media = MediaQuery.of(context);
|
||||||
seedColor: seed,
|
return MediaQuery(
|
||||||
brightness: Brightness.light,
|
data: media.copyWith(
|
||||||
primary: seed,
|
textScaler: media.textScaler.clamp(
|
||||||
secondary: AppColors.accent,
|
minScaleFactor: 0.9,
|
||||||
error: AppColors.danger,
|
maxScaleFactor: 1.15,
|
||||||
),
|
),
|
||||||
scaffoldBackgroundColor: AppColors.surface,
|
),
|
||||||
textTheme: GoogleFonts.interTextTheme().apply(
|
child: child ?? const SizedBox.shrink(),
|
||||||
bodyColor: AppColors.text,
|
);
|
||||||
displayColor: AppColors.text,
|
},
|
||||||
),
|
locale: state.localeCode == 'en-US'
|
||||||
pageTransitionsTheme: const PageTransitionsTheme(
|
? const Locale('en', 'US')
|
||||||
builders: {
|
: const Locale('id', 'ID'),
|
||||||
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
supportedLocales: AppStrings.supportedLocales,
|
||||||
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
localizationsDelegates: const [
|
||||||
TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(),
|
AppStringsDelegate(),
|
||||||
},
|
GlobalMaterialLocalizations.delegate,
|
||||||
),
|
GlobalWidgetsLocalizations.delegate,
|
||||||
appBarTheme: const AppBarTheme(
|
GlobalCupertinoLocalizations.delegate,
|
||||||
centerTitle: false,
|
],
|
||||||
backgroundColor: AppColors.surface,
|
theme: ThemeData(
|
||||||
foregroundColor: AppColors.text,
|
useMaterial3: true,
|
||||||
elevation: 0,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
surfaceTintColor: Colors.transparent,
|
colorScheme: ColorScheme.fromSeed(
|
||||||
),
|
seedColor: seed,
|
||||||
cardTheme: CardThemeData(
|
brightness: Brightness.light,
|
||||||
elevation: 0,
|
primary: seed,
|
||||||
color: AppColors.surfaceRaised,
|
secondary: AppColors.accent,
|
||||||
surfaceTintColor: Colors.transparent,
|
error: AppColors.danger,
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: const BorderSide(color: AppColors.border),
|
|
||||||
),
|
),
|
||||||
),
|
scaffoldBackgroundColor: AppColors.surface,
|
||||||
dividerTheme: const DividerThemeData(
|
textTheme: GoogleFonts.interTextTheme().apply(
|
||||||
color: AppColors.border,
|
bodyColor: AppColors.text,
|
||||||
thickness: 1,
|
displayColor: AppColors.text,
|
||||||
space: 1,
|
),
|
||||||
),
|
pageTransitionsTheme: const PageTransitionsTheme(
|
||||||
iconButtonTheme: IconButtonThemeData(
|
builders: {
|
||||||
style: IconButton.styleFrom(
|
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
appBarTheme: const AppBarTheme(
|
||||||
|
centerTitle: false,
|
||||||
|
backgroundColor: AppColors.surface,
|
||||||
foregroundColor: AppColors.text,
|
foregroundColor: AppColors.text,
|
||||||
backgroundColor: Colors.white,
|
elevation: 0,
|
||||||
|
surfaceTintColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
cardTheme: CardThemeData(
|
||||||
|
elevation: 0,
|
||||||
|
color: AppColors.surfaceRaised,
|
||||||
|
surfaceTintColor: Colors.transparent,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
side: const BorderSide(color: AppColors.border),
|
side: const BorderSide(color: AppColors.border),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
dividerTheme: const DividerThemeData(
|
||||||
navigationBarTheme: NavigationBarThemeData(
|
color: AppColors.border,
|
||||||
elevation: 0,
|
thickness: 1,
|
||||||
height: 76,
|
space: 1,
|
||||||
backgroundColor: Colors.white,
|
),
|
||||||
indicatorColor: const Color(0xFFDDEAFE),
|
iconButtonTheme: IconButtonThemeData(
|
||||||
surfaceTintColor: Colors.transparent,
|
style: IconButton.styleFrom(
|
||||||
labelTextStyle: WidgetStateProperty.resolveWith(
|
foregroundColor: AppColors.text,
|
||||||
(states) => TextStyle(
|
backgroundColor: Colors.white,
|
||||||
fontSize: 12,
|
shape: RoundedRectangleBorder(
|
||||||
fontWeight: states.contains(WidgetState.selected)
|
borderRadius: BorderRadius.circular(8),
|
||||||
? FontWeight.w800
|
side: const BorderSide(color: AppColors.border),
|
||||||
: FontWeight.w500,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
filledButtonTheme: FilledButtonThemeData(
|
elevation: 0,
|
||||||
style: FilledButton.styleFrom(
|
height: 76,
|
||||||
backgroundColor: seed,
|
backgroundColor: Colors.white,
|
||||||
foregroundColor: Colors.white,
|
indicatorColor: const Color(0xFFDDEAFE),
|
||||||
minimumSize: const Size(0, 50),
|
surfaceTintColor: Colors.transparent,
|
||||||
textStyle: const TextStyle(fontWeight: FontWeight.w800),
|
labelTextStyle: WidgetStateProperty.resolveWith(
|
||||||
|
(states) => TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: states.contains(WidgetState.selected)
|
||||||
|
? FontWeight.w800
|
||||||
|
: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
filledButtonTheme: FilledButtonThemeData(
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: seed,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
minimumSize: const Size(0, 50),
|
||||||
|
textStyle: const TextStyle(fontWeight: FontWeight.w800),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
minimumSize: const Size(0, 50),
|
||||||
|
foregroundColor: seed,
|
||||||
|
textStyle: const TextStyle(fontWeight: FontWeight.w800),
|
||||||
|
side: const BorderSide(color: AppColors.border),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
snackBarTheme: SnackBarThemeData(
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
backgroundColor: AppColors.text,
|
||||||
|
contentTextStyle: GoogleFonts.inter(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
filled: true,
|
||||||
style: OutlinedButton.styleFrom(
|
fillColor: Colors.white,
|
||||||
minimumSize: const Size(0, 50),
|
contentPadding:
|
||||||
foregroundColor: seed,
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||||
textStyle: const TextStyle(fontWeight: FontWeight.w800),
|
border: OutlineInputBorder(
|
||||||
side: const BorderSide(color: AppColors.border),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: AppColors.border),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: AppColors.border),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: seed, width: 1.5),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
snackBarTheme: SnackBarThemeData(
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
backgroundColor: AppColors.text,
|
|
||||||
contentTextStyle: GoogleFonts.inter(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: const BorderSide(color: AppColors.border),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: const BorderSide(color: AppColors.border),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: const BorderSide(color: seed, width: 1.5),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -4,14 +4,26 @@ class AppState {
|
|||||||
final bool online;
|
final bool online;
|
||||||
final String? role;
|
final String? role;
|
||||||
final String? serverUrl;
|
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(
|
return AppState(
|
||||||
online: online ?? this.online,
|
online: online ?? this.online,
|
||||||
role: role ?? this.role,
|
role: role ?? this.role,
|
||||||
serverUrl: serverUrl ?? this.serverUrl,
|
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 setOnline(bool value) => emit(state.copyWith(online: value));
|
||||||
|
|
||||||
|
void setLocaleCode(String value) => emit(state.copyWith(localeCode: value));
|
||||||
|
|
||||||
void clearSession() => emit(const AppState(online: true));
|
void clearSession() => emit(const AppState(online: true));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
|
|
||||||
import '../core/constants/app_constants.dart';
|
import '../core/constants/app_constants.dart';
|
||||||
import '../core/ai/obstacle_alert_strategy.dart';
|
import '../core/ai/obstacle_alert_strategy.dart';
|
||||||
import '../core/ai/obstacle_analyzer.dart';
|
import '../core/ai/obstacle_analyzer.dart';
|
||||||
@ -85,12 +83,5 @@ Future<void> initDependencies() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await ignoreInitFailure(() => sl<TtsService>().init(), label: 'TTS init');
|
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();
|
sl<VoiceCommandHandler>().loadDefaultCommands();
|
||||||
if (!kIsWeb) {
|
|
||||||
await sl<FcmService>().init();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,9 @@ class AppConstants {
|
|||||||
if (!cleaned.startsWith('http://') && !cleaned.startsWith('https://')) {
|
if (!cleaned.startsWith('http://') && !cleaned.startsWith('https://')) {
|
||||||
cleaned = 'http://$cleaned';
|
cleaned = 'http://$cleaned';
|
||||||
}
|
}
|
||||||
|
cleaned = cleaned
|
||||||
|
.replaceFirst('://localhost', '://127.0.0.1')
|
||||||
|
.replaceFirst('://0.0.0.0', '://127.0.0.1');
|
||||||
while (cleaned.endsWith('/')) {
|
while (cleaned.endsWith('/')) {
|
||||||
cleaned = cleaned.substring(0, cleaned.length - 1);
|
cleaned = cleaned.substring(0, cleaned.length - 1);
|
||||||
}
|
}
|
||||||
@ -61,7 +64,6 @@ class AppConstants {
|
|||||||
await prefs.setString(_selectedYoloModelKey, path);
|
await prefs.setString(_selectedYoloModelKey, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Agora App ID tetap bisa dioverride saat build: --dart-define=AGORA_APP_ID=...
|
// Set at build time with: --dart-define=AGORA_APP_ID=your_app_id
|
||||||
static const String agoraAppId = String.fromEnvironment('AGORA_APP_ID',
|
static const String agoraAppId = String.fromEnvironment('AGORA_APP_ID');
|
||||||
defaultValue: 'e36c2b6592e34cfda1f6ea6432a5e68d');
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,8 @@ bool _looksTechnical(String message) {
|
|||||||
'duplicate key',
|
'duplicate key',
|
||||||
'constraint',
|
'constraint',
|
||||||
'sql [',
|
'sql [',
|
||||||
|
'illegal base64',
|
||||||
|
'base64 character',
|
||||||
];
|
];
|
||||||
return blocked.any(lower.contains);
|
return blocked.any(lower.contains);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,19 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class AppStrings {
|
class AppStrings {
|
||||||
final String localeCode;
|
final String localeCode;
|
||||||
|
|
||||||
const AppStrings(this.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(
|
String get walkGuideStarted => _pick(
|
||||||
id: 'WalkGuide dimulai',
|
id: 'WalkGuide dimulai',
|
||||||
@ -29,3 +39,21 @@ class AppStrings {
|
|||||||
return localeCode == 'en-US' ? en : id;
|
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:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import '../constants/app_constants.dart';
|
import '../constants/app_constants.dart';
|
||||||
import '../storage/secure_storage.dart';
|
import '../storage/secure_storage.dart';
|
||||||
|
|
||||||
@ -24,8 +25,15 @@ class ApiClient {
|
|||||||
_dio.interceptors.addAll([
|
_dio.interceptors.addAll([
|
||||||
_AuthInterceptor(_secureStorage, _dio),
|
_AuthInterceptor(_secureStorage, _dio),
|
||||||
_ErrorInterceptor(),
|
_ErrorInterceptor(),
|
||||||
LogInterceptor(requestBody: true, responseBody: true),
|
|
||||||
]);
|
]);
|
||||||
|
if (kDebugMode) {
|
||||||
|
_dio.interceptors.add(LogInterceptor(
|
||||||
|
requestBody: false,
|
||||||
|
responseBody: false,
|
||||||
|
requestHeader: false,
|
||||||
|
responseHeader: false,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dio get dio => _dio;
|
Dio get dio => _dio;
|
||||||
@ -42,7 +50,8 @@ class _AuthInterceptor extends Interceptor {
|
|||||||
_AuthInterceptor(this._storage, this._dio);
|
_AuthInterceptor(this._storage, this._dio);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
|
void onRequest(
|
||||||
|
RequestOptions options, RequestInterceptorHandler handler) async {
|
||||||
final token = await _storage.getAccessToken();
|
final token = await _storage.getAccessToken();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
options.headers['Authorization'] = 'Bearer $token';
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
|
|||||||
@ -166,6 +166,11 @@ class CallService {
|
|||||||
debugPrint('Agora remote user offline: $remoteUid $reason');
|
debugPrint('Agora remote user offline: $remoteUid $reason');
|
||||||
_onRemoteUserOffline?.call();
|
_onRemoteUserOffline?.call();
|
||||||
},
|
},
|
||||||
|
onRemoteAudioStateChanged: (_, remoteUid, state, reason, __) {
|
||||||
|
debugPrint(
|
||||||
|
'Agora remote audio state: uid=$remoteUid state=$state reason=$reason',
|
||||||
|
);
|
||||||
|
},
|
||||||
onError: (type, msg) {
|
onError: (type, msg) {
|
||||||
debugPrint('Agora error: $type $msg');
|
debugPrint('Agora error: $type $msg');
|
||||||
if (!joinCompleter.isCompleted) joinCompleter.complete(false);
|
if (!joinCompleter.isCompleted) joinCompleter.complete(false);
|
||||||
@ -175,9 +180,18 @@ class CallService {
|
|||||||
await _engine!.setChannelProfile(
|
await _engine!.setChannelProfile(
|
||||||
ChannelProfileType.channelProfileCommunication,
|
ChannelProfileType.channelProfileCommunication,
|
||||||
);
|
);
|
||||||
|
await _engine!.setClientRole(role: ClientRoleType.clientRoleBroadcaster);
|
||||||
|
await _engine!.setAudioProfile(
|
||||||
|
profile: AudioProfileType.audioProfileDefault,
|
||||||
|
scenario: AudioScenarioType.audioScenarioMeeting,
|
||||||
|
);
|
||||||
await _engine!.enableAudio();
|
await _engine!.enableAudio();
|
||||||
await _engine!.enableLocalAudio(true);
|
await _engine!.enableLocalAudio(true);
|
||||||
|
await _engine!.muteAllRemoteAudioStreams(false);
|
||||||
await _engine!.muteLocalAudioStream(false);
|
await _engine!.muteLocalAudioStream(false);
|
||||||
|
await _engine!.adjustRecordingSignalVolume(100);
|
||||||
|
await _engine!.adjustPlaybackSignalVolume(100);
|
||||||
|
await _engine!.setDefaultAudioRouteToSpeakerphone(true);
|
||||||
await _engine!.setEnableSpeakerphone(true);
|
await _engine!.setEnableSpeakerphone(true);
|
||||||
await _engine!.joinChannel(
|
await _engine!.joinChannel(
|
||||||
token: token ?? '',
|
token: token ?? '',
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import '../network/api_client.dart';
|
|||||||
|
|
||||||
class FcmService {
|
class FcmService {
|
||||||
final ApiClient _apiClient;
|
final ApiClient _apiClient;
|
||||||
final FirebaseMessaging _messaging = FirebaseMessaging.instance;
|
|
||||||
final FlutterLocalNotificationsPlugin _localNotifications =
|
final FlutterLocalNotificationsPlugin _localNotifications =
|
||||||
FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
@ -18,6 +17,7 @@ class FcmService {
|
|||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
if (kIsWeb) return;
|
if (kIsWeb) return;
|
||||||
try {
|
try {
|
||||||
|
final messaging = FirebaseMessaging.instance;
|
||||||
await _localNotifications.initialize(
|
await _localNotifications.initialize(
|
||||||
const InitializationSettings(
|
const InitializationSettings(
|
||||||
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
|
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
|
||||||
@ -31,10 +31,10 @@ class FcmService {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await _messaging.requestPermission(alert: true, badge: true, sound: true);
|
await messaging.requestPermission(alert: true, badge: true, sound: true);
|
||||||
final token = await _messaging.getToken();
|
final token = await messaging.getToken();
|
||||||
if (token != null) await syncToken(token);
|
if (token != null) await syncToken(token);
|
||||||
FirebaseMessaging.instance.onTokenRefresh.listen(syncToken);
|
messaging.onTokenRefresh.listen(syncToken);
|
||||||
FirebaseMessaging.onMessage.listen((message) {
|
FirebaseMessaging.onMessage.listen((message) {
|
||||||
debugPrint('FCM foreground: ${message.data}');
|
debugPrint('FCM foreground: ${message.data}');
|
||||||
_showLocalNotification(message);
|
_showLocalNotification(message);
|
||||||
@ -55,6 +55,10 @@ class FcmService {
|
|||||||
|
|
||||||
Future<void> syncToken(String token) async {
|
Future<void> syncToken(String token) async {
|
||||||
try {
|
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});
|
await _apiClient.dio.put('/auth/fcm-token', data: {'fcmToken': token});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('FCM token sync skipped: $e');
|
debugPrint('FCM token sync skipped: $e');
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:battery_plus/battery_plus.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ import 'offline_queue_service.dart';
|
|||||||
class LocationReporterService {
|
class LocationReporterService {
|
||||||
final ApiClient _apiClient;
|
final ApiClient _apiClient;
|
||||||
final OfflineQueueService _offlineQueue;
|
final OfflineQueueService _offlineQueue;
|
||||||
|
final Battery _battery = Battery();
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
|
|
||||||
LocationReporterService(this._apiClient, this._offlineQueue);
|
LocationReporterService(this._apiClient, this._offlineQueue);
|
||||||
@ -32,12 +34,14 @@ class LocationReporterService {
|
|||||||
try {
|
try {
|
||||||
await Geolocator.requestPermission();
|
await Geolocator.requestPermission();
|
||||||
final position = await Geolocator.getCurrentPosition();
|
final position = await Geolocator.getCurrentPosition();
|
||||||
|
final batteryLevel = await _readBatteryLevel();
|
||||||
await _apiClient.dio.post('/user/location', data: {
|
await _apiClient.dio.post('/user/location', data: {
|
||||||
'lat': position.latitude,
|
'lat': position.latitude,
|
||||||
'lng': position.longitude,
|
'lng': position.longitude,
|
||||||
'accuracy': position.accuracy,
|
'accuracy': position.accuracy,
|
||||||
'speed': position.speed,
|
'speed': position.speed,
|
||||||
'heading': position.heading,
|
'heading': position.heading,
|
||||||
|
if (batteryLevel != null) 'batteryLevel': batteryLevel,
|
||||||
});
|
});
|
||||||
} on DioException catch (_) {
|
} on DioException catch (_) {
|
||||||
await _offlineQueue.enqueue(OfflineRequest(
|
await _offlineQueue.enqueue(OfflineRequest(
|
||||||
@ -50,4 +54,12 @@ class LocationReporterService {
|
|||||||
// GPS permission can be unavailable during desktop/web testing.
|
// 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
|
/// Callback yang dipanggil saat command terdeteksi
|
||||||
/// Registered oleh router/screen yang relevan
|
/// Registered oleh router/screen yang relevan
|
||||||
typedef CommandCallback = void Function(VoiceCommandKey key);
|
typedef CommandCallback = void Function(VoiceCommandKey key);
|
||||||
|
typedef CommandRouter = void Function(String route);
|
||||||
|
typedef CommandAction = void Function();
|
||||||
|
|
||||||
class VoiceCommandHandler {
|
class VoiceCommandHandler {
|
||||||
final SttService _stt;
|
final SttService _stt;
|
||||||
@ -26,9 +28,19 @@ class VoiceCommandHandler {
|
|||||||
|
|
||||||
List<VoiceCommand> _commands = [];
|
List<VoiceCommand> _commands = [];
|
||||||
CommandCallback? onCommand;
|
CommandCallback? onCommand;
|
||||||
|
CommandRouter? _router;
|
||||||
|
final Map<VoiceCommandKey, CommandAction> _actions = {};
|
||||||
|
|
||||||
VoiceCommandHandler(this._stt, this._tts);
|
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) {
|
void loadCommands(List<VoiceCommand> commands) {
|
||||||
_commands = commands;
|
_commands = commands;
|
||||||
_stt.onResult = _processText;
|
_stt.onResult = _processText;
|
||||||
@ -66,9 +78,28 @@ class VoiceCommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleCommand(VoiceCommandKey key) {
|
void _handleCommand(VoiceCommandKey key) {
|
||||||
|
_routeFor(key);
|
||||||
|
_actions[key]?.call();
|
||||||
onCommand?.call(key);
|
onCommand?.call(key);
|
||||||
// Built-in actions for TTS-only commands
|
// Built-in actions for TTS-only commands
|
||||||
if (key == VoiceCommandKey.repeatLast) _tts.repeatLast();
|
if (key == VoiceCommandKey.repeatLast) _tts.repeatLast();
|
||||||
if (key == VoiceCommandKey.stopTts) _tts.stop();
|
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,163 +151,182 @@ class _AuthFrame extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFEAF4FF),
|
backgroundColor: const Color(0xFFEAF4FF),
|
||||||
body: Stack(
|
body: LayoutBuilder(
|
||||||
children: [
|
builder: (context, constraints) {
|
||||||
const Positioned.fill(
|
final compact =
|
||||||
child: DecoratedBox(
|
constraints.maxWidth < 480 || constraints.maxHeight < 720;
|
||||||
decoration: BoxDecoration(
|
return Stack(
|
||||||
gradient: LinearGradient(
|
children: [
|
||||||
begin: Alignment.topLeft,
|
const Positioned.fill(
|
||||||
end: Alignment.bottomRight,
|
child: DecoratedBox(
|
||||||
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
|
decoration: BoxDecoration(
|
||||||
),
|
gradient: LinearGradient(
|
||||||
),
|
begin: Alignment.topLeft,
|
||||||
),
|
end: Alignment.bottomRight,
|
||||||
),
|
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
|
||||||
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,
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
width: 260,
|
|
||||||
height: 260,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 430),
|
|
||||||
child: TweenAnimationBuilder<double>(
|
|
||||||
tween: Tween(begin: 18, end: 0),
|
|
||||||
duration: const Duration(milliseconds: 520),
|
|
||||||
curve: Curves.easeOutCubic,
|
|
||||||
builder: (_, offset, child) => Opacity(
|
|
||||||
opacity: (1 - offset / 18).clamp(0.0, 1.0),
|
|
||||||
child: Transform.translate(
|
|
||||||
offset: Offset(0, offset),
|
|
||||||
child: child,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: RepaintBoundary(
|
),
|
||||||
child: Container(
|
),
|
||||||
decoration: BoxDecoration(
|
Positioned(
|
||||||
color: Colors.white.withValues(alpha: 0.96),
|
top: compact ? -70 : -90,
|
||||||
borderRadius: BorderRadius.circular(30),
|
right: compact ? -70 : -60,
|
||||||
border: Border.all(
|
child: Container(
|
||||||
color: Colors.white.withValues(alpha: 0.8)),
|
width: compact ? 180 : 260,
|
||||||
boxShadow: [
|
height: compact ? 180 : 260,
|
||||||
BoxShadow(
|
decoration: BoxDecoration(
|
||||||
color:
|
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
|
||||||
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
|
shape: BoxShape.circle,
|
||||||
blurRadius: 40,
|
),
|
||||||
offset: const Offset(0, 20),
|
),
|
||||||
),
|
),
|
||||||
],
|
Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior:
|
||||||
|
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
compact ? 14 : 24,
|
||||||
|
compact ? 12 : 24,
|
||||||
|
compact ? 14 : 24,
|
||||||
|
20 + MediaQuery.of(context).viewInsets.bottom,
|
||||||
|
),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
|
||||||
|
child: TweenAnimationBuilder<double>(
|
||||||
|
tween: Tween(begin: 18, end: 0),
|
||||||
|
duration: const Duration(milliseconds: 520),
|
||||||
|
curve: Curves.easeOutCubic,
|
||||||
|
builder: (_, offset, child) => Opacity(
|
||||||
|
opacity: (1 - offset / 18).clamp(0.0, 1.0),
|
||||||
|
child: Transform.translate(
|
||||||
|
offset: Offset(0, offset),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: RepaintBoundary(
|
||||||
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
|
child: Container(
|
||||||
child: Column(
|
decoration: BoxDecoration(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
color: Colors.white.withValues(alpha: 0.96),
|
||||||
children: [
|
borderRadius:
|
||||||
Row(
|
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: compact ? 24 : 40,
|
||||||
|
offset: const Offset(0, 18),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
compact ? 18 : 24,
|
||||||
|
compact ? 18 : 26,
|
||||||
|
compact ? 18 : 24,
|
||||||
|
compact ? 18 : 24,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Row(
|
||||||
width: 56,
|
children: [
|
||||||
height: 56,
|
Container(
|
||||||
decoration: BoxDecoration(
|
width: compact ? 44 : 56,
|
||||||
gradient: const LinearGradient(
|
height: compact ? 44 : 56,
|
||||||
colors: [
|
decoration: BoxDecoration(
|
||||||
Color(0xFF2563EB),
|
gradient: const LinearGradient(
|
||||||
Color(0xFF0891B2)
|
colors: [
|
||||||
|
Color(0xFF2563EB),
|
||||||
|
Color(0xFF0891B2)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
color: Color(0xFF0F172A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: compact ? 14 : 16),
|
||||||
|
if (!compact)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFEFF6FF),
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.shield_outlined,
|
||||||
|
size: 14, color: Color(0xFF1D4ED8)),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
'Secure Assistive Navigation',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Color(0xFF1D4ED8),
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(18),
|
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.navigation_rounded,
|
if (!compact) const SizedBox(height: 18),
|
||||||
color: Colors.white, size: 30),
|
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),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(height: 6),
|
||||||
const Expanded(
|
Text(
|
||||||
child: Text(
|
subtitle,
|
||||||
'WalkGuide',
|
maxLines: 2,
|
||||||
style: TextStyle(
|
overflow: TextOverflow.ellipsis,
|
||||||
fontSize: 18,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w900,
|
color: Color(0xFF64748B),
|
||||||
color: Color(0xFF0F172A),
|
height: 1.35,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: compact ? 18 : 26),
|
||||||
|
child,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 10, vertical: 6),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFEFF6FF),
|
|
||||||
borderRadius: BorderRadius.circular(999),
|
|
||||||
),
|
|
||||||
child: const Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.shield_outlined,
|
|
||||||
size: 14, color: Color(0xFF1D4ED8)),
|
|
||||||
SizedBox(width: 6),
|
|
||||||
Text(
|
|
||||||
'Secure Assistive Navigation',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Color(0xFF1D4ED8),
|
|
||||||
fontSize: 11,
|
|
||||||
fontWeight: FontWeight.w800,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 18),
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineMedium
|
|
||||||
?.copyWith(
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
color: const Color(0xFF0F172A),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
Text(
|
|
||||||
subtitle,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Color(0xFF64748B),
|
|
||||||
height: 1.35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 26),
|
|
||||||
child,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -299,133 +299,151 @@ class _AuthFrame extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFEAF4FF),
|
backgroundColor: const Color(0xFFEAF4FF),
|
||||||
body: Stack(
|
body: LayoutBuilder(
|
||||||
children: [
|
builder: (context, constraints) {
|
||||||
const Positioned.fill(
|
final compact =
|
||||||
child: DecoratedBox(
|
constraints.maxWidth < 480 || constraints.maxHeight < 720;
|
||||||
decoration: BoxDecoration(
|
return Stack(
|
||||||
gradient: LinearGradient(
|
children: [
|
||||||
begin: Alignment.topLeft,
|
const Positioned.fill(
|
||||||
end: Alignment.bottomRight,
|
child: DecoratedBox(
|
||||||
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
|
decoration: BoxDecoration(
|
||||||
),
|
gradient: LinearGradient(
|
||||||
),
|
begin: Alignment.topLeft,
|
||||||
),
|
end: Alignment.bottomRight,
|
||||||
),
|
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
|
||||||
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,
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
width: 260,
|
|
||||||
height: 260,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 430),
|
|
||||||
child: TweenAnimationBuilder<double>(
|
|
||||||
tween: Tween(begin: 18, end: 0),
|
|
||||||
duration: const Duration(milliseconds: 520),
|
|
||||||
curve: Curves.easeOutCubic,
|
|
||||||
builder: (_, offset, child) => Opacity(
|
|
||||||
opacity: (1 - offset / 18).clamp(0.0, 1.0),
|
|
||||||
child: Transform.translate(
|
|
||||||
offset: Offset(0, offset),
|
|
||||||
child: child,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: RepaintBoundary(
|
),
|
||||||
child: Container(
|
),
|
||||||
decoration: BoxDecoration(
|
Positioned(
|
||||||
color: Colors.white.withValues(alpha: 0.96),
|
top: compact ? -70 : -90,
|
||||||
borderRadius: BorderRadius.circular(30),
|
right: compact ? -70 : -60,
|
||||||
border: Border.all(
|
child: Container(
|
||||||
color: Colors.white.withValues(alpha: 0.8)),
|
width: compact ? 180 : 260,
|
||||||
boxShadow: [
|
height: compact ? 180 : 260,
|
||||||
BoxShadow(
|
decoration: BoxDecoration(
|
||||||
color:
|
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
|
||||||
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
|
shape: BoxShape.circle,
|
||||||
blurRadius: 40,
|
),
|
||||||
offset: const Offset(0, 20),
|
),
|
||||||
),
|
),
|
||||||
],
|
Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior:
|
||||||
|
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
compact ? 14 : 24,
|
||||||
|
compact ? 12 : 24,
|
||||||
|
compact ? 14 : 24,
|
||||||
|
20 + MediaQuery.of(context).viewInsets.bottom,
|
||||||
|
),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
|
||||||
|
child: TweenAnimationBuilder<double>(
|
||||||
|
tween: Tween(begin: 18, end: 0),
|
||||||
|
duration: const Duration(milliseconds: 520),
|
||||||
|
curve: Curves.easeOutCubic,
|
||||||
|
builder: (_, offset, child) => Opacity(
|
||||||
|
opacity: (1 - offset / 18).clamp(0.0, 1.0),
|
||||||
|
child: Transform.translate(
|
||||||
|
offset: Offset(0, offset),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: RepaintBoundary(
|
||||||
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
|
child: Container(
|
||||||
child: Column(
|
decoration: BoxDecoration(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
color: Colors.white.withValues(alpha: 0.96),
|
||||||
children: [
|
borderRadius:
|
||||||
Row(
|
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: compact ? 24 : 40,
|
||||||
|
offset: const Offset(0, 18),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
compact ? 18 : 24,
|
||||||
|
compact ? 18 : 26,
|
||||||
|
compact ? 18 : 24,
|
||||||
|
compact ? 18 : 24,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Row(
|
||||||
width: 56,
|
children: [
|
||||||
height: 56,
|
Container(
|
||||||
decoration: BoxDecoration(
|
width: compact ? 44 : 56,
|
||||||
color: const Color(0xFF1D4ED8),
|
height: compact ? 44 : 56,
|
||||||
borderRadius: BorderRadius.circular(18),
|
decoration: BoxDecoration(
|
||||||
),
|
color: const Color(0xFF1D4ED8),
|
||||||
child: const Icon(Icons.navigation_rounded,
|
borderRadius: BorderRadius.circular(16),
|
||||||
color: Colors.white, size: 30),
|
),
|
||||||
),
|
child: Icon(Icons.navigation_rounded,
|
||||||
const SizedBox(width: 12),
|
color: Colors.white,
|
||||||
const Expanded(
|
size: compact ? 26 : 30),
|
||||||
child: Text(
|
|
||||||
'WalkGuide',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
color: Color(0xFF0F172A),
|
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
const Expanded(
|
||||||
|
child: Text(
|
||||||
|
'WalkGuide',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: Color(0xFF0F172A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
subtitle,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Color(0xFF64748B),
|
||||||
|
height: 1.35,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: compact ? 18 : 26),
|
||||||
|
child,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 22),
|
),
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineMedium
|
|
||||||
?.copyWith(
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
color: const Color(0xFF0F172A),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
Text(
|
|
||||||
subtitle,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Color(0xFF64748B),
|
|
||||||
height: 1.35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 26),
|
|
||||||
child,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import '../../app/injection_container.dart';
|
import '../../app/injection_container.dart';
|
||||||
|
import '../../core/errors/friendly_error.dart';
|
||||||
import '../../core/services/call_service.dart';
|
import '../../core/services/call_service.dart';
|
||||||
import '../../core/services/haptic_service.dart';
|
import '../../core/services/haptic_service.dart';
|
||||||
import '../../core/services/tts_service.dart';
|
import '../../core/services/tts_service.dart';
|
||||||
@ -63,65 +64,71 @@ class _CallScreenState extends State<CallScreen>
|
|||||||
unawaited(_finishRemoteEnded());
|
unawaited(_finishRemoteEnded());
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
final invite = await runFriendly<Map<String, dynamic>>(
|
||||||
final invite = await callService.startPairedCall();
|
() => callService.startPairedCall(),
|
||||||
if (!mounted) return;
|
onError: _failCall,
|
||||||
if (invite == null) {
|
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.');
|
_failCall('Panggilan gagal. Pastikan sudah pairing dan server aktif.');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
_otherId = _asInt(invite['receiverId']);
|
|
||||||
_activeChannel = invite['channelName']?.toString();
|
|
||||||
setState(() => _phase = _CallPhase.calling);
|
|
||||||
sl<TtsService>().speak(
|
|
||||||
'Panggilan dikirim ke ${widget.targetLabel}. Menunggu jawaban.',
|
|
||||||
);
|
|
||||||
_startAcceptedPolling();
|
|
||||||
_ringTimeout?.cancel();
|
|
||||||
_ringTimeout = Timer(const Duration(seconds: 45), () {
|
|
||||||
if (!mounted || _phase == _CallPhase.connected) return;
|
|
||||||
_failCall('Panggilan tidak dijawab.');
|
|
||||||
});
|
|
||||||
} catch (_) {
|
|
||||||
if (!mounted) return;
|
|
||||||
_failCall('Panggilan gagal. Server tidak merespons.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_otherId = _asInt(invite['receiverId']);
|
||||||
|
_activeChannel = invite['channelName']?.toString();
|
||||||
|
setState(() => _phase = _CallPhase.calling);
|
||||||
|
sl<TtsService>().speak(
|
||||||
|
'Panggilan dikirim ke ${widget.targetLabel}. Menunggu jawaban.',
|
||||||
|
);
|
||||||
|
_startAcceptedPolling();
|
||||||
|
_ringTimeout?.cancel();
|
||||||
|
_ringTimeout = Timer(const Duration(seconds: 45), () {
|
||||||
|
if (!mounted || _phase == _CallPhase.connected) return;
|
||||||
|
_failCall('Panggilan tidak dijawab.');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startAcceptedPolling() {
|
void _startAcceptedPolling() {
|
||||||
_acceptedPoll?.cancel();
|
_acceptedPoll?.cancel();
|
||||||
_acceptedPoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
_acceptedPoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
||||||
if (!mounted || _activeChannel == null) return;
|
if (!mounted || _activeChannel == null) return;
|
||||||
try {
|
final state = await runFriendly<Map<String, dynamic>>(
|
||||||
final state = await sl<CallService>()
|
() => sl<CallService>()
|
||||||
.getCallState(_activeChannel)
|
.getCallState(_activeChannel)
|
||||||
.timeout(const Duration(seconds: 3));
|
.timeout(const Duration(seconds: 3)),
|
||||||
final status = state?['status']?.toString();
|
onError: (_) {},
|
||||||
if (status == 'ENDED') {
|
fallback: 'Polling panggilan gagal.',
|
||||||
await _finishRemoteEnded();
|
);
|
||||||
return;
|
if (state == null) return;
|
||||||
}
|
final status = state['status']?.toString();
|
||||||
if (status == 'ACCEPTED') {
|
if (status == 'ENDED') {
|
||||||
_markRemoteConnected();
|
await _finishRemoteEnded();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
final accepted = await sl<CallService>()
|
|
||||||
.getAcceptedCall()
|
|
||||||
.timeout(const Duration(seconds: 3));
|
|
||||||
if (accepted?['type']?.toString() != 'CALL_ACCEPTED') return;
|
|
||||||
final channel = accepted?['channelName']?.toString();
|
|
||||||
if (_activeChannel != null &&
|
|
||||||
channel != null &&
|
|
||||||
channel.isNotEmpty &&
|
|
||||||
channel != _activeChannel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_markRemoteConnected();
|
|
||||||
} catch (_) {
|
|
||||||
// Keep ringing; a short network hiccup should not cancel the call UI.
|
|
||||||
}
|
}
|
||||||
|
if (status == 'ACCEPTED') {
|
||||||
|
_markRemoteConnected();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final accepted = await runFriendly<Map<String, dynamic>>(
|
||||||
|
() => sl<CallService>()
|
||||||
|
.getAcceptedCall()
|
||||||
|
.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 &&
|
||||||
|
channel != null &&
|
||||||
|
channel.isNotEmpty &&
|
||||||
|
channel != _activeChannel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_markRemoteConnected();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +326,12 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
|
|||||||
setState(() => _responding = true);
|
setState(() => _responding = true);
|
||||||
sl<TtsService>().speak('Menerima panggilan.');
|
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 (!mounted) return;
|
||||||
if (!joined || _joinedChannel == null || widget.callerId == null) {
|
if (!joined || _joinedChannel == null || widget.callerId == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -350,14 +362,16 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
|
|||||||
_statePoll?.cancel();
|
_statePoll?.cancel();
|
||||||
_statePoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
_statePoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
||||||
if (!mounted || _joinedChannel == null) return;
|
if (!mounted || _joinedChannel == null) return;
|
||||||
try {
|
final state = await runFriendly<Map<String, dynamic>>(
|
||||||
final state = await sl<CallService>()
|
() => sl<CallService>()
|
||||||
.getCallState(_joinedChannel)
|
.getCallState(_joinedChannel)
|
||||||
.timeout(const Duration(seconds: 3));
|
.timeout(const Duration(seconds: 3)),
|
||||||
if (state?['status']?.toString() == 'ENDED') {
|
onError: (_) {},
|
||||||
await _finishIncomingRemoteEnded();
|
fallback: 'Polling panggilan masuk gagal.',
|
||||||
}
|
);
|
||||||
} catch (_) {}
|
if (state?['status']?.toString() == 'ENDED') {
|
||||||
|
await _finishIncomingRemoteEnded();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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) ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
// ââ€Âۉâ€Â€ Live location (WebSocket) ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||||
LatLng? _liveLatLng;
|
LatLng? _liveLatLng;
|
||||||
bool _liveConnected = false;
|
bool _liveConnected = false;
|
||||||
|
DateTime? _lastRealtimeStatusReload;
|
||||||
final MapController _mapController = MapController();
|
final MapController _mapController = MapController();
|
||||||
|
|
||||||
// ââ€Âۉâ€Â€ Pulse animation for live dot ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
// ââ€Âۉâ€Â€ Pulse animation for live dot ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||||
@ -133,12 +134,13 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
|||||||
'User',
|
'User',
|
||||||
userOnline: userStatus?['online'] as bool? ?? false,
|
userOnline: userStatus?['online'] as bool? ?? false,
|
||||||
userLastSeen: userStatus?['lastSeenAt']?.toString(),
|
userLastSeen: userStatus?['lastSeenAt']?.toString(),
|
||||||
battery: userStatus?['battery'] as int?,
|
battery: (userStatus?['battery'] as num?)?.toInt(),
|
||||||
speed: userStatus?['lastSpeed'] as double?,
|
speed: (userStatus?['lastSpeed'] as num?)?.toDouble(),
|
||||||
obstaclesTotal: userStatus?['obstaclesToday'] as int? ??
|
obstaclesTotal: (userStatus?['obstaclesToday'] as num?)?.toInt() ??
|
||||||
dashboard?['obstaclesToday'] as int? ??
|
(dashboard?['obstaclesToday'] as num?)?.toInt() ??
|
||||||
0,
|
0,
|
||||||
unreadNotif: dashboard?['unreadNotifCount'] as int? ?? 0,
|
unreadNotif:
|
||||||
|
(dashboard?['unreadNotifCount'] as num?)?.toInt() ?? 0,
|
||||||
unreadSos: sosPending,
|
unreadSos: sosPending,
|
||||||
lastLat: lastLoc?['lat'] != null
|
lastLat: lastLoc?['lat'] != null
|
||||||
? (lastLoc!['lat'] as num).toDouble()
|
? (lastLoc!['lat'] as num).toDouble()
|
||||||
@ -247,6 +249,12 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
|||||||
_liveConnected = true;
|
_liveConnected = true;
|
||||||
});
|
});
|
||||||
_moveMapSafely(newPos);
|
_moveMapSafely(newPos);
|
||||||
|
final now = DateTime.now();
|
||||||
|
if (_lastRealtimeStatusReload == null ||
|
||||||
|
now.difference(_lastRealtimeStatusReload!).inSeconds >= 15) {
|
||||||
|
_lastRealtimeStatusReload = now;
|
||||||
|
unawaited(_loadAll(silent: true));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ws.subscribeSos((sosData) {
|
ws.subscribeSos((sosData) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
import '../../../core/secure_storage.dart';
|
import '../../../core/secure_storage.dart';
|
||||||
import '../../auth/presentation/login_screen.dart';
|
import '../../auth/presentation/login_screen.dart';
|
||||||
import '../../../../main.dart';
|
|
||||||
|
|
||||||
class UserDashboardScreen extends StatefulWidget {
|
class UserDashboardScreen extends StatefulWidget {
|
||||||
const UserDashboardScreen({super.key});
|
const UserDashboardScreen({super.key});
|
||||||
@ -12,7 +11,8 @@ class UserDashboardScreen extends StatefulWidget {
|
|||||||
State<UserDashboardScreen> createState() => _UserDashboardScreenState();
|
State<UserDashboardScreen> createState() => _UserDashboardScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerProviderStateMixin {
|
class _UserDashboardScreenState extends State<UserDashboardScreen>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
CameraController? _camCtrl;
|
CameraController? _camCtrl;
|
||||||
late AnimationController _radarCtrl;
|
late AnimationController _radarCtrl;
|
||||||
late Animation<double> _radarAnim;
|
late Animation<double> _radarAnim;
|
||||||
@ -31,8 +31,10 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initCamera() async {
|
Future<void> _initCamera() async {
|
||||||
|
final cameras = await availableCameras();
|
||||||
if (cameras.isEmpty) return;
|
if (cameras.isEmpty) return;
|
||||||
_camCtrl = CameraController(cameras[0], ResolutionPreset.high, enableAudio: false);
|
_camCtrl = CameraController(cameras[0], ResolutionPreset.medium,
|
||||||
|
enableAudio: false);
|
||||||
await _camCtrl!.initialize();
|
await _camCtrl!.initialize();
|
||||||
if (mounted) setState(() {});
|
if (mounted) setState(() {});
|
||||||
}
|
}
|
||||||
@ -85,7 +87,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
|||||||
gradient: RadialGradient(
|
gradient: RadialGradient(
|
||||||
colors: [
|
colors: [
|
||||||
Colors.transparent,
|
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],
|
stops: const [0.5, 1.0],
|
||||||
radius: 1.4,
|
radius: 1.4,
|
||||||
@ -127,7 +130,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
|||||||
),
|
),
|
||||||
child: Row(children: [
|
child: Row(children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withValues(alpha: 0.54),
|
color: Colors.black.withValues(alpha: 0.54),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
@ -158,7 +162,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _logout,
|
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(
|
style: IconButton.styleFrom(
|
||||||
backgroundColor: Colors.redAccent.withValues(alpha: 0.8),
|
backgroundColor: Colors.redAccent.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
@ -204,15 +209,19 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
|||||||
color: const Color(0x33F59E0B),
|
color: const Color(0x33F59E0B),
|
||||||
borderRadius: BorderRadius.circular(7),
|
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),
|
const SizedBox(width: 10),
|
||||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Text('Obstacle ahead',
|
Text('Obstacle ahead',
|
||||||
style: GoogleFonts.inter(
|
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',
|
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: [
|
child: Column(children: [
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Expanded(child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
Expanded(
|
||||||
|
child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
||||||
const SizedBox(width: 12),
|
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),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
@ -290,7 +302,8 @@ class _RadarPainter extends CustomPainter {
|
|||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.2;
|
..strokeWidth = 1.2;
|
||||||
for (final r in [48.0, 34.0, 20.0]) {
|
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);
|
canvas.drawCircle(center, r, paint);
|
||||||
}
|
}
|
||||||
paint
|
paint
|
||||||
@ -301,4 +314,4 @@ class _RadarPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,35 +61,40 @@ class _NavState extends Cubit<int> {
|
|||||||
StreamSubscription<Position>? _posStream;
|
StreamSubscription<Position>? _posStream;
|
||||||
|
|
||||||
void _set(_NavPhase p, String status) {
|
void _set(_NavPhase p, String status) {
|
||||||
|
if (isClosed) return;
|
||||||
phase = p;
|
phase = p;
|
||||||
statusText = status;
|
statusText = status;
|
||||||
_notify();
|
_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _notify() => emit(state + 1);
|
void _notify() {
|
||||||
|
if (isClosed) return;
|
||||||
|
emit(state + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// ── locate ──────────────────────────────────────────────────────────────
|
// ── locate ──────────────────────────────────────────────────────────────
|
||||||
Future<bool> locate() async {
|
Future<bool> locate() async {
|
||||||
_set(_NavPhase.locating, 'Mencari lokasi GPS…');
|
_set(_NavPhase.locating, 'Mencari lokasi GPS…');
|
||||||
final located = await guarded<bool>(
|
final located = await guarded<bool>(
|
||||||
() async {
|
() async {
|
||||||
LocationPermission perm = await Geolocator.checkPermission();
|
LocationPermission perm = await Geolocator.checkPermission();
|
||||||
if (perm == LocationPermission.denied) {
|
if (perm == LocationPermission.denied) {
|
||||||
perm = await Geolocator.requestPermission();
|
perm = await Geolocator.requestPermission();
|
||||||
}
|
}
|
||||||
if (perm == LocationPermission.deniedForever) {
|
if (perm == LocationPermission.deniedForever) {
|
||||||
_set(_NavPhase.error, 'Izin lokasi diblokir permanen.');
|
_set(_NavPhase.error, 'Izin lokasi diblokir permanen.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final pos = await Geolocator.getCurrentPosition(
|
final pos = await Geolocator.getCurrentPosition(
|
||||||
desiredAccuracy: LocationAccuracy.high,
|
desiredAccuracy: LocationAccuracy.high,
|
||||||
).timeout(const Duration(seconds: 12));
|
).timeout(const Duration(seconds: 12));
|
||||||
currentPosition = LatLng(pos.latitude, pos.longitude);
|
currentPosition = LatLng(pos.latitude, pos.longitude);
|
||||||
_set(_NavPhase.idle, 'Lokasi ditemukan. Cari tujuan atau ketuk peta.');
|
_set(_NavPhase.idle, 'Lokasi ditemukan. Cari tujuan atau ketuk peta.');
|
||||||
_reportToBackend(pos);
|
_reportToBackend(pos);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onTimeout: () => _set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
|
onTimeout: () =>
|
||||||
|
_set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
|
||||||
onError: (_) => _set(_NavPhase.error,
|
onError: (_) => _set(_NavPhase.error,
|
||||||
'Lokasi belum bisa dibaca. Pastikan GPS dan izin lokasi aktif.'),
|
'Lokasi belum bisa dibaca. Pastikan GPS dan izin lokasi aktif.'),
|
||||||
);
|
);
|
||||||
@ -113,33 +118,37 @@ class _NavState extends Cubit<int> {
|
|||||||
Future<List<_Place>> searchPlaces(String query) async {
|
Future<List<_Place>> searchPlaces(String query) async {
|
||||||
if (query.trim().isEmpty) return const [];
|
if (query.trim().isEmpty) return const [];
|
||||||
return await guarded<List<_Place>>(
|
return await guarded<List<_Place>>(
|
||||||
() async {
|
() async {
|
||||||
final res = await Dio().get(
|
final res = await Dio().get(
|
||||||
'https://nominatim.openstreetmap.org/search',
|
'https://nominatim.openstreetmap.org/search',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'q': query,
|
'q': query,
|
||||||
'format': 'jsonv2',
|
'format': 'jsonv2',
|
||||||
'limit': 6,
|
'limit': 6,
|
||||||
'addressdetails': 0,
|
'addressdetails': 0,
|
||||||
if (currentPosition != null) 'viewbox': _viewbox(currentPosition!),
|
if (currentPosition != null)
|
||||||
if (currentPosition != null) 'bounded': 0,
|
'viewbox': _viewbox(currentPosition!),
|
||||||
},
|
if (currentPosition != null) 'bounded': 0,
|
||||||
options: Options(
|
},
|
||||||
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
|
options: Options(
|
||||||
receiveTimeout: const Duration(seconds: 8),
|
headers: {
|
||||||
),
|
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
|
||||||
);
|
},
|
||||||
final list = res.data as List;
|
receiveTimeout: const Duration(seconds: 8),
|
||||||
return list.map((e) {
|
),
|
||||||
final lat = double.tryParse(e['lat'].toString()) ?? 0;
|
);
|
||||||
final lng = double.tryParse(e['lon'].toString()) ?? 0;
|
final list = res.data as List;
|
||||||
return _Place(
|
return list.map((e) {
|
||||||
displayName: e['display_name'].toString(),
|
final lat = double.tryParse(e['lat'].toString()) ?? 0;
|
||||||
position: LatLng(lat, lng),
|
final lng = double.tryParse(e['lon'].toString()) ?? 0;
|
||||||
);
|
return _Place(
|
||||||
}).toList();
|
displayName: e['display_name'].toString(),
|
||||||
},
|
position: LatLng(lat, lng),
|
||||||
) ?? const [];
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
) ??
|
||||||
|
const [];
|
||||||
}
|
}
|
||||||
|
|
||||||
String _viewbox(LatLng c) =>
|
String _viewbox(LatLng c) =>
|
||||||
@ -148,23 +157,25 @@ class _NavState extends Cubit<int> {
|
|||||||
// ── reverse geocode ──────────────────────────────────────────────────────
|
// ── reverse geocode ──────────────────────────────────────────────────────
|
||||||
Future<String> reverseGeocode(LatLng pos) async {
|
Future<String> reverseGeocode(LatLng pos) async {
|
||||||
return await guarded<String>(
|
return await guarded<String>(
|
||||||
() async {
|
() async {
|
||||||
final res = await Dio().get(
|
final res = await Dio().get(
|
||||||
'https://nominatim.openstreetmap.org/reverse',
|
'https://nominatim.openstreetmap.org/reverse',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'lat': pos.latitude,
|
'lat': pos.latitude,
|
||||||
'lon': pos.longitude,
|
'lon': pos.longitude,
|
||||||
'format': 'jsonv2',
|
'format': 'jsonv2',
|
||||||
},
|
},
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
|
headers: {
|
||||||
receiveTimeout: const Duration(seconds: 6),
|
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
|
||||||
),
|
},
|
||||||
);
|
receiveTimeout: const Duration(seconds: 6),
|
||||||
return res.data['display_name']?.toString() ??
|
),
|
||||||
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
|
);
|
||||||
},
|
return res.data['display_name']?.toString() ??
|
||||||
) ??
|
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
|
||||||
|
},
|
||||||
|
) ??
|
||||||
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
|
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,47 +191,47 @@ class _NavState extends Cubit<int> {
|
|||||||
final origin = currentPosition!;
|
final origin = currentPosition!;
|
||||||
await guarded<void>(
|
await guarded<void>(
|
||||||
() async {
|
() async {
|
||||||
final url = 'http://router.project-osrm.org/route/v1/foot/'
|
final url = 'http://router.project-osrm.org/route/v1/foot/'
|
||||||
'${origin.longitude},${origin.latitude};'
|
'${origin.longitude},${origin.latitude};'
|
||||||
'${dest.position.longitude},${dest.position.latitude}'
|
'${dest.position.longitude},${dest.position.latitude}'
|
||||||
'?steps=true&geometries=geojson&overview=full&annotations=false';
|
'?steps=true&geometries=geojson&overview=full&annotations=false';
|
||||||
|
|
||||||
final res = await Dio().get(
|
final res = await Dio().get(
|
||||||
url,
|
url,
|
||||||
options: Options(receiveTimeout: const Duration(seconds: 12)),
|
options: Options(receiveTimeout: const Duration(seconds: 12)),
|
||||||
);
|
);
|
||||||
|
|
||||||
final route = res.data['routes'][0];
|
final route = res.data['routes'][0];
|
||||||
final geom = route['geometry']['coordinates'] as List;
|
final geom = route['geometry']['coordinates'] as List;
|
||||||
routePoints = geom.map((c) {
|
routePoints = geom.map((c) {
|
||||||
final lst = c as List;
|
final lst = c as List;
|
||||||
return LatLng((lst[1] as num).toDouble(), (lst[0] as num).toDouble());
|
return LatLng((lst[1] as num).toDouble(), (lst[0] as num).toDouble());
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
// parse steps
|
// parse steps
|
||||||
final legs = route['legs'] as List;
|
final legs = route['legs'] as List;
|
||||||
final rawSteps = <_Step>[];
|
final rawSteps = <_Step>[];
|
||||||
for (final leg in legs) {
|
for (final leg in legs) {
|
||||||
for (final step in leg['steps'] as List) {
|
for (final step in leg['steps'] as List) {
|
||||||
final maneuver = step['maneuver'] as Map;
|
final maneuver = step['maneuver'] as Map;
|
||||||
final instruction = _buildInstruction(maneuver, step);
|
final instruction = _buildInstruction(maneuver, step);
|
||||||
final dist = (step['distance'] as num?)?.toDouble() ?? 0;
|
final dist = (step['distance'] as num?)?.toDouble() ?? 0;
|
||||||
final loc = maneuver['location'] as List;
|
final loc = maneuver['location'] as List;
|
||||||
rawSteps.add(_Step(
|
rawSteps.add(_Step(
|
||||||
instruction: instruction,
|
instruction: instruction,
|
||||||
distanceM: dist,
|
distanceM: dist,
|
||||||
point:
|
point: LatLng(
|
||||||
LatLng((loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
|
(loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
steps = rawSteps;
|
||||||
steps = rawSteps;
|
currentStepIndex = 0;
|
||||||
currentStepIndex = 0;
|
|
||||||
|
|
||||||
_set(_NavPhase.navigating,
|
_set(_NavPhase.navigating,
|
||||||
steps.isNotEmpty ? steps[0].instruction : 'Ikuti rute biru.');
|
steps.isNotEmpty ? steps[0].instruction : 'Ikuti rute biru.');
|
||||||
_notify();
|
_notify();
|
||||||
_startTracking();
|
_startTracking();
|
||||||
},
|
},
|
||||||
onError: (_) => _set(_NavPhase.error,
|
onError: (_) => _set(_NavPhase.error,
|
||||||
'Gagal mendapat rute. Periksa koneksi lalu coba lagi.'),
|
'Gagal mendapat rute. Periksa koneksi lalu coba lagi.'),
|
||||||
@ -289,6 +300,7 @@ class _NavState extends Cubit<int> {
|
|||||||
distanceFilter: 5,
|
distanceFilter: 5,
|
||||||
),
|
),
|
||||||
).listen((pos) {
|
).listen((pos) {
|
||||||
|
if (isClosed) return;
|
||||||
currentPosition = LatLng(pos.latitude, pos.longitude);
|
currentPosition = LatLng(pos.latitude, pos.longitude);
|
||||||
_reportToBackend(pos);
|
_reportToBackend(pos);
|
||||||
_updateStep();
|
_updateStep();
|
||||||
@ -298,6 +310,7 @@ class _NavState extends Cubit<int> {
|
|||||||
|
|
||||||
void _updateStep() {
|
void _updateStep() {
|
||||||
if (steps.isEmpty || phase != _NavPhase.navigating) return;
|
if (steps.isEmpty || phase != _NavPhase.navigating) return;
|
||||||
|
if (currentPosition == null) return;
|
||||||
if (currentStepIndex >= steps.length - 1) return;
|
if (currentStepIndex >= steps.length - 1) return;
|
||||||
|
|
||||||
final current = steps[currentStepIndex];
|
final current = steps[currentStepIndex];
|
||||||
@ -317,6 +330,7 @@ class _NavState extends Cubit<int> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void stopNavigation() {
|
void stopNavigation() {
|
||||||
|
if (isClosed) return;
|
||||||
_posStream?.cancel();
|
_posStream?.cancel();
|
||||||
_posStream = null;
|
_posStream = null;
|
||||||
destination = 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(
|
await runFriendlyAction(
|
||||||
() async {
|
() async {
|
||||||
final clean = AppConstants.normalizeServerUrl(_url.text);
|
final clean = AppConstants.normalizeServerUrl(_url.text);
|
||||||
|
await sl<ApiClient>().init(clean);
|
||||||
final res = await Dio(BaseOptions(
|
final res = await Dio(BaseOptions(
|
||||||
connectTimeout: AppConstants.pingTimeout,
|
connectTimeout: AppConstants.pingTimeout,
|
||||||
receiveTimeout: AppConstants.pingTimeout,
|
receiveTimeout: AppConstants.pingTimeout,
|
||||||
@ -47,7 +48,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
: 'Server merespons, tetapi format ping tidak valid.';
|
: 'Server merespons, tetapi format ping tidak valid.';
|
||||||
},
|
},
|
||||||
onError: (message) => _message = message,
|
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);
|
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 _useUsbUrl() => setState(() => _url.text = 'http://127.0.0.1:8080');
|
||||||
|
void _useAndroidEmulatorUrl() =>
|
||||||
|
setState(() => _url.text = 'http://10.0.2.2:8080');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -96,12 +100,23 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
SafeArea(
|
SafeArea(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
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(
|
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: Center(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 460),
|
constraints:
|
||||||
|
BoxConstraints(maxWidth: compact ? 380 : 520),
|
||||||
child: TweenAnimationBuilder<double>(
|
child: TweenAnimationBuilder<double>(
|
||||||
tween: Tween(begin: 18, end: 0),
|
tween: Tween(begin: 18, end: 0),
|
||||||
duration: const Duration(milliseconds: 520),
|
duration: const Duration(milliseconds: 520),
|
||||||
@ -114,7 +129,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withValues(alpha: 0.96),
|
color: Colors.white.withValues(alpha: 0.96),
|
||||||
borderRadius: BorderRadius.circular(28),
|
borderRadius:
|
||||||
|
BorderRadius.circular(compact ? 22 : 28),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Colors.white.withValues(alpha: 0.7)),
|
color: Colors.white.withValues(alpha: 0.7)),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
@ -126,13 +142,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(28),
|
borderRadius:
|
||||||
|
BorderRadius.circular(compact ? 22 : 28),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding: EdgeInsets.fromLTRB(
|
||||||
const EdgeInsets.fromLTRB(22, 22, 22, 20),
|
compact ? 14 : 22,
|
||||||
|
compact ? 14 : 22,
|
||||||
|
compact ? 14 : 22,
|
||||||
|
compact ? 14 : 20,
|
||||||
|
),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Color(0xFF071226),
|
color: Color(0xFF071226),
|
||||||
),
|
),
|
||||||
@ -143,37 +164,38 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 48,
|
width: compact ? 38 : 48,
|
||||||
height: 48,
|
height: compact ? 38 : 48,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF2563EB),
|
color: const Color(0xFF2563EB),
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(16),
|
BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: const Icon(
|
child: Icon(
|
||||||
Icons.navigation_rounded,
|
Icons.navigation_rounded,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 28),
|
size: compact ? 24 : 28,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
const Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'WalkGuide Link',
|
'WalkGuide',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20,
|
fontSize: compact ? 16 : 20,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 18),
|
SizedBox(height: compact ? 14 : 18),
|
||||||
const Text(
|
Text(
|
||||||
'Connect to Server',
|
'Connect to Server',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 30,
|
fontSize: compact ? 22 : 30,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
@ -191,7 +213,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(22),
|
padding: EdgeInsets.all(compact ? 14 : 22),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.stretch,
|
CrossAxisAlignment.stretch,
|
||||||
@ -217,13 +239,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
label: 'USB: 127.0.0.1',
|
label: 'USB: 127.0.0.1',
|
||||||
onTap: _useUsbUrl,
|
onTap: _useUsbUrl,
|
||||||
),
|
),
|
||||||
|
_HintChip(
|
||||||
|
icon: Icons.phone_android_outlined,
|
||||||
|
label: 'Emulator: 10.0.2.2',
|
||||||
|
onTap: _useAndroidEmulatorUrl,
|
||||||
|
),
|
||||||
const _HintChip(
|
const _HintChip(
|
||||||
icon: Icons.wifi_tethering_outlined,
|
icon: Icons.wifi_tethering_outlined,
|
||||||
label: 'Wi-Fi: IP laptop',
|
label: 'Wi-Fi: IP laptop',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
SizedBox(height: compact ? 12 : 16),
|
||||||
OutlinedButton.icon(
|
OutlinedButton.icon(
|
||||||
onPressed: _loading ? null : _test,
|
onPressed: _loading ? null : _test,
|
||||||
icon: _loading
|
icon: _loading
|
||||||
@ -251,15 +278,17 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
|||||||
label: const Text('Continue'),
|
label: const Text('Continue'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 18),
|
if (!compact) ...[
|
||||||
const Center(
|
const SizedBox(height: 18),
|
||||||
child: Text(
|
const Center(
|
||||||
'v1.0.0 | Spring Boot + Flutter',
|
child: Text(
|
||||||
style: TextStyle(
|
'v1.0.0 | Spring Boot + Flutter',
|
||||||
fontSize: 11,
|
style: TextStyle(
|
||||||
color: Color(0xFF94A3B8)),
|
fontSize: 11,
|
||||||
|
color: Color(0xFF94A3B8)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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);
|
setState(() => _saving = true);
|
||||||
// Apply TTS locally dulu
|
// Apply TTS locally dulu
|
||||||
await sl<TtsService>().setLanguage(_ttsLanguage);
|
await sl<TtsService>().setLanguage(_ttsLanguage);
|
||||||
|
context.read<AppCubit>().setLocaleCode(_ttsLanguage);
|
||||||
if (_hapticEnabled) {
|
if (_hapticEnabled) {
|
||||||
await sl<HapticService>().success();
|
await sl<HapticService>().success();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -243,9 +243,18 @@ class _SosScreenState extends State<SosScreen>
|
|||||||
bloc: _sosCubit,
|
bloc: _sosCubit,
|
||||||
builder: (context, sosState) {
|
builder: (context, sosState) {
|
||||||
final sending = sosState.phase == SosPhase.sending;
|
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(
|
return SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: EdgeInsets.all(pagePadding),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@ -278,14 +287,14 @@ class _SosScreenState extends State<SosScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
SizedBox(height: sectionGap),
|
||||||
|
|
||||||
// Active SOS banner
|
// Active SOS banner
|
||||||
if (_hasActiveSos)
|
if (_hasActiveSos)
|
||||||
_ActiveSosBanner(
|
_ActiveSosBanner(
|
||||||
event: _events.first, onRefresh: _loadHistory),
|
event: _events.first, onRefresh: _loadHistory),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
SizedBox(height: sectionGap),
|
||||||
|
|
||||||
// SOS Button
|
// SOS Button
|
||||||
Center(
|
Center(
|
||||||
@ -312,6 +321,8 @@ class _SosScreenState extends State<SosScreen>
|
|||||||
? 'SOS aktif — Guardian sudah mendapat notifikasi'
|
? 'SOS aktif — Guardian sudah mendapat notifikasi'
|
||||||
: 'Tekan tombol untuk kirim SOS darurat ke Guardian',
|
: 'Tekan tombol untuk kirim SOS darurat ke Guardian',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: _hasActiveSos
|
color: _hasActiveSos
|
||||||
? const Color(0xFFDC2626)
|
? const Color(0xFFDC2626)
|
||||||
@ -321,22 +332,25 @@ class _SosScreenState extends State<SosScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 28),
|
SizedBox(height: sectionGap),
|
||||||
|
|
||||||
// History section
|
// History section
|
||||||
const Text(
|
if (!landscapeTight) ...[
|
||||||
'Riwayat SOS',
|
const Text(
|
||||||
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
|
'Riwayat SOS',
|
||||||
),
|
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _SosHistory(
|
child: _SosHistory(
|
||||||
loading: _historyLoading,
|
loading: _historyLoading,
|
||||||
error: _historyError,
|
error: _historyError,
|
||||||
events: _events,
|
events: _events,
|
||||||
onRefresh: _loadHistory,
|
onRefresh: _loadHistory,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
] else
|
||||||
|
const Spacer(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -361,8 +375,16 @@ class _SosButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return SizedBox.square(
|
||||||
dimension: 200,
|
dimension: dimension,
|
||||||
child: FilledButton(
|
child: FilledButton(
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
@ -377,14 +399,14 @@ class _SosButton extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
active ? Icons.emergency : Icons.emergency_outlined,
|
active ? Icons.emergency : Icons.emergency_outlined,
|
||||||
size: 48,
|
size: dimension < 150 ? 34 : 48,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
SizedBox(height: dimension < 150 ? 3 : 6),
|
||||||
Text(
|
Text(
|
||||||
'SOS',
|
'SOS',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 38,
|
fontSize: dimension < 150 ? 28 : 38,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
letterSpacing: 2,
|
letterSpacing: 2,
|
||||||
@ -402,8 +424,16 @@ class _SendingIndicator extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return SizedBox.square(
|
||||||
dimension: 200,
|
dimension: dimension,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFDC2626).withValues(alpha: 0.15),
|
color: const Color(0xFFDC2626).withValues(alpha: 0.15),
|
||||||
|
|||||||
@ -144,6 +144,7 @@ class _WalkGuideScreenState extends State<WalkGuideScreen>
|
|||||||
() async {
|
() async {
|
||||||
final cameras = await availableCameras();
|
final cameras = await availableCameras();
|
||||||
if (cameras.isEmpty) return;
|
if (cameras.isEmpty) return;
|
||||||
|
await sl<YoloDetector>().init();
|
||||||
final backCamera = cameras.firstWhere(
|
final backCamera = cameras.firstWhere(
|
||||||
(camera) => camera.lensDirection == CameraLensDirection.back,
|
(camera) => camera.lensDirection == CameraLensDirection.back,
|
||||||
orElse: () => cameras.first,
|
orElse: () => cameras.first,
|
||||||
@ -808,6 +809,7 @@ class _Page extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final compact = MediaQuery.sizeOf(context).height < 520;
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
@ -818,15 +820,20 @@ class _Page extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
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(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 46,
|
width: compact ? 38 : 46,
|
||||||
height: 46,
|
height: compact ? 38 : 46,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF2563EB),
|
color: const Color(0xFF2563EB),
|
||||||
borderRadius: BorderRadius.circular(14),
|
borderRadius: BorderRadius.circular(14),
|
||||||
@ -839,21 +846,24 @@ class _Page extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.navigation_rounded,
|
child: Icon(Icons.navigation_rounded,
|
||||||
color: Colors.white, size: 26),
|
color: Colors.white, size: compact ? 22 : 26),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
SizedBox(width: compact ? 10 : 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(title,
|
Text(title,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.headlineSmall
|
.headlineSmall
|
||||||
?.copyWith(
|
?.copyWith(
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
color: const Color(0xFF0F172A),
|
color: const Color(0xFF0F172A),
|
||||||
|
fontSize: compact ? 22 : null,
|
||||||
)),
|
)),
|
||||||
if (subtitle != null)
|
if (subtitle != null)
|
||||||
Text(subtitle!,
|
Text(subtitle!,
|
||||||
@ -866,7 +876,7 @@ class _Page extends StatelessWidget {
|
|||||||
...?actions,
|
...?actions,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
SizedBox(height: compact ? 8 : 16),
|
||||||
Expanded(child: child),
|
Expanded(child: child),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,36 +1,207 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:camera/camera.dart';
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'app/injection_container.dart';
|
import 'app/injection_container.dart';
|
||||||
import 'app/app.dart';
|
import 'app/app.dart';
|
||||||
|
import 'core/constants/app_constants.dart';
|
||||||
import 'core/utils/init_guard.dart';
|
import 'core/utils/init_guard.dart';
|
||||||
|
|
||||||
List<CameraDescription> cameras = [];
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
await runZonedGuarded(
|
||||||
|
() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
_installGlobalErrorUi();
|
||||||
|
await AppConstants.clearServerUrl();
|
||||||
|
|
||||||
cameras = await ignoreInitFailure(
|
if (!kIsWeb) {
|
||||||
availableCameras,
|
final firebaseApp = await ignoreInitFailure(
|
||||||
label: 'Camera init',
|
() => Firebase.initializeApp(),
|
||||||
) ??
|
label: 'Firebase init',
|
||||||
[];
|
);
|
||||||
|
if (firebaseApp != null) {
|
||||||
|
FirebaseMessaging.onBackgroundMessage(
|
||||||
|
_firebaseMessagingBackgroundHandler,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!kIsWeb) {
|
try {
|
||||||
await ignoreInitFailure(() => Firebase.initializeApp(),
|
await initDependencies();
|
||||||
label: 'Firebase init');
|
} catch (error, stackTrace) {
|
||||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init GetIt dependencies
|
String _formatDetails() {
|
||||||
await initDependencies();
|
final stack = stackTrace;
|
||||||
|
if (stack == null || stack.isEmpty) return details;
|
||||||
runApp(const WalkGuideApp());
|
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();
|
super.initState();
|
||||||
_loadVoiceCommands();
|
_loadVoiceCommands();
|
||||||
_startHardwareShortcuts();
|
_startHardwareShortcuts();
|
||||||
sl<SttService>().startListening();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_startVoiceListening();
|
||||||
|
});
|
||||||
sl<VoiceCommandHandler>().onCommand = (key) {
|
sl<VoiceCommandHandler>().onCommand = (key) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
switch (key) {
|
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 {
|
Future<void> _loadVoiceCommands() async {
|
||||||
await runFriendlyAction(
|
await runFriendlyAction(
|
||||||
() async {
|
() async {
|
||||||
@ -182,42 +195,41 @@ class _AppShell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return LayoutBuilder(
|
||||||
backgroundColor: AppColors.surface,
|
builder: (context, constraints) {
|
||||||
body: AnimatedSwitcher(
|
final useRail = constraints.maxWidth >= 760;
|
||||||
duration: const Duration(milliseconds: 180),
|
final content = AnimatedSwitcher(
|
||||||
switchInCurve: Curves.easeOutCubic,
|
duration: const Duration(milliseconds: 180),
|
||||||
switchOutCurve: Curves.easeInCubic,
|
switchInCurve: Curves.easeOutCubic,
|
||||||
child: KeyedSubtree(
|
switchOutCurve: Curves.easeInCubic,
|
||||||
key: ValueKey(location),
|
child: KeyedSubtree(
|
||||||
child: child,
|
key: ValueKey(location),
|
||||||
),
|
child: child,
|
||||||
),
|
),
|
||||||
bottomNavigationBar: DecoratedBox(
|
);
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
return Scaffold(
|
||||||
border: const Border(top: BorderSide(color: AppColors.border)),
|
backgroundColor: AppColors.surface,
|
||||||
boxShadow: [
|
body: useRail
|
||||||
BoxShadow(
|
? Row(
|
||||||
color: Colors.black.withValues(alpha: 0.06),
|
children: [
|
||||||
blurRadius: 18,
|
_RailNavigation(
|
||||||
offset: const Offset(0, -8),
|
items: items,
|
||||||
),
|
selectedIndex: _selectedIndex,
|
||||||
],
|
),
|
||||||
),
|
const VerticalDivider(width: 1, color: AppColors.border),
|
||||||
child: NavigationBar(
|
Expanded(child: content),
|
||||||
selectedIndex: _selectedIndex,
|
],
|
||||||
onDestinationSelected: (index) => context.go(items[index].route),
|
)
|
||||||
destinations: [
|
: content,
|
||||||
for (final item in items)
|
bottomNavigationBar: useRail
|
||||||
NavigationDestination(
|
? null
|
||||||
icon: Icon(item.icon),
|
: _BottomScrollNavigation(
|
||||||
selectedIcon: Icon(item.selectedIcon),
|
items: items,
|
||||||
label: item.label,
|
selectedIndex: _selectedIndex,
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,6 +239,194 @@ class _AppShell extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.06),
|
||||||
|
blurRadius: 18,
|
||||||
|
offset: const Offset(0, -8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _ShellItem {
|
class _ShellItem {
|
||||||
final String label;
|
final String label;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
|||||||
@ -19,62 +19,127 @@ class FeaturePage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Padding(
|
child: LayoutBuilder(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),
|
builder: (context, constraints) {
|
||||||
child: Column(
|
final short = constraints.maxHeight < 520;
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
final compact = constraints.maxWidth < 420 || short;
|
||||||
children: [
|
final wide = constraints.maxWidth >= 900;
|
||||||
TweenAnimationBuilder<double>(
|
final horizontal = compact ? 12.0 : 20.0;
|
||||||
tween: Tween(begin: 12, end: 0),
|
return Padding(
|
||||||
duration: const Duration(milliseconds: 360),
|
padding: EdgeInsets.fromLTRB(
|
||||||
curve: Curves.easeOutCubic,
|
horizontal,
|
||||||
builder: (_, offset, child) => Opacity(
|
short ? 8 : 12,
|
||||||
opacity: (1 - offset / 12).clamp(0.0, 1.0),
|
horizontal,
|
||||||
child: Transform.translate(
|
short ? 10 : 14,
|
||||||
offset: Offset(0, offset),
|
),
|
||||||
child: child,
|
child: Center(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: wide ? 1160 : double.infinity,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TweenAnimationBuilder<double>(
|
||||||
|
tween: Tween(begin: 12, end: 0),
|
||||||
|
duration: const Duration(milliseconds: 360),
|
||||||
|
curve: Curves.easeOutCubic,
|
||||||
|
builder: (_, offset, child) => Opacity(
|
||||||
|
opacity: (1 - offset / 12).clamp(0.0, 1.0),
|
||||||
|
child: Transform.translate(
|
||||||
|
offset: Offset(0, offset),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: _FeatureHeading(
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
compact: compact,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (trailing != null) trailing!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: short ? 8 : (compact ? 12 : 16)),
|
||||||
|
Expanded(
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineSmall
|
|
||||||
?.copyWith(
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
color: AppColors.text,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
subtitle,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: AppColors.muted,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (trailing != null) trailing!,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 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,
|
||||||
|
maxLines: short ? 1 : 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||||
|
fontSize: compact ? 22 : null,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: AppColors.text,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class FeatureEmptyPanel extends StatelessWidget {
|
class FeatureEmptyPanel extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String title;
|
final String title;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import Foundation
|
|||||||
|
|
||||||
import agora_rtc_engine
|
import agora_rtc_engine
|
||||||
import audio_session
|
import audio_session
|
||||||
|
import battery_plus
|
||||||
import connectivity_plus
|
import connectivity_plus
|
||||||
import device_info_plus
|
import device_info_plus
|
||||||
import firebase_core
|
import firebase_core
|
||||||
@ -27,6 +28,7 @@ import sqlite3_flutter_libs
|
|||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin"))
|
AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin"))
|
||||||
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
||||||
|
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
|
||||||
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
||||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||||
|
|||||||
@ -65,6 +65,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.25"
|
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:
|
bloc:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -571,6 +587,11 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.2.0"
|
version: "7.2.0"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_map:
|
flutter_map:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1652,6 +1673,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.1"
|
version: "0.3.1"
|
||||||
|
upower:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: upower
|
||||||
|
sha256: cf042403154751180affa1d15614db7fa50234bc2373cd21c3db666c38543ebf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.0"
|
||||||
uuid:
|
uuid:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -9,6 +9,8 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
# State management
|
# State management
|
||||||
flutter_bloc: ^8.1.6
|
flutter_bloc: ^8.1.6
|
||||||
@ -50,6 +52,7 @@ dependencies:
|
|||||||
|
|
||||||
# Location
|
# Location
|
||||||
geolocator: ^12.0.0
|
geolocator: ^12.0.0
|
||||||
|
battery_plus: ^6.2.3
|
||||||
|
|
||||||
# Agora VoIP
|
# Agora VoIP
|
||||||
agora_rtc_engine: ^6.3.2
|
agora_rtc_engine: ^6.3.2
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <agora_rtc_engine/agora_rtc_engine_plugin.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 <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||||
#include <firebase_core/firebase_core_plugin_c_api.h>
|
#include <firebase_core/firebase_core_plugin_c_api.h>
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
@ -21,6 +22,8 @@
|
|||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
AgoraRtcEnginePluginRegisterWithRegistrar(
|
AgoraRtcEnginePluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin"));
|
registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin"));
|
||||||
|
BatteryPlusWindowsPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("BatteryPlusWindowsPlugin"));
|
||||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||||
FirebaseCorePluginCApiRegisterWithRegistrar(
|
FirebaseCorePluginCApiRegisterWithRegistrar(
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
agora_rtc_engine
|
agora_rtc_engine
|
||||||
|
battery_plus
|
||||||
connectivity_plus
|
connectivity_plus
|
||||||
firebase_core
|
firebase_core
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user