Compare commits
5
Commits
latest
...
e2fe4ce6c4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2fe4ce6c4 | ||
|
|
cfb68fd8bb | ||
|
|
9fd2b2aa4b | ||
|
|
2854afdd22 | ||
|
|
02c8189ada |
@@ -0,0 +1,79 @@
|
|||||||
|
name: Build Android APK
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- 'refactor/**'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-android:
|
||||||
|
name: Build Release APKs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/cirruslabs/flutter:3.19.3
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Configure Git Safe Directory
|
||||||
|
run: |
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
git config --global --add safe.directory '*'
|
||||||
|
|
||||||
|
- name: Make Gradlew Executable
|
||||||
|
run: chmod +x android/gradlew
|
||||||
|
|
||||||
|
- name: Inspect Build Environment
|
||||||
|
run: |
|
||||||
|
flutter --version
|
||||||
|
java -version
|
||||||
|
|
||||||
|
- name: Fetch Flutter Dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Run Code Analysis & Tests
|
||||||
|
run: |
|
||||||
|
flutter analyze
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
- name: Build Universal Release APK
|
||||||
|
run: flutter build apk --release
|
||||||
|
|
||||||
|
- name: Build Split-per-ABI Release APKs
|
||||||
|
run: flutter build apk --release --split-per-abi
|
||||||
|
|
||||||
|
- name: Organize Artifacts
|
||||||
|
run: |
|
||||||
|
mkdir -p release-apks
|
||||||
|
# Copy universal APK
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-release.apk release-apks/oggauer-gemeindetrommler-universal-release.apk
|
||||||
|
fi
|
||||||
|
# Copy split APKs
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-arm64-v8a-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk release-apks/oggauer-gemeindetrommler-arm64-v8a.apk
|
||||||
|
fi
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk release-apks/oggauer-gemeindetrommler-armeabi-v7a.apk
|
||||||
|
fi
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-x86_64-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-x86_64-release.apk release-apks/oggauer-gemeindetrommler-x86_64.apk
|
||||||
|
fi
|
||||||
|
echo "=== Generated APK Artifacts ==="
|
||||||
|
ls -lah release-apks/
|
||||||
|
|
||||||
|
- name: Upload APKs to Gitea Artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: oggauer-gemeindetrommler-apks
|
||||||
|
path: release-apks/*.apk
|
||||||
|
retention-days: 30
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
name: Build Android APK
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- 'refactor/**'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-android:
|
||||||
|
name: Build Release APKs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/cirruslabs/flutter:3.19.3
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Configure Git Safe Directory
|
||||||
|
run: |
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
git config --global --add safe.directory '*'
|
||||||
|
|
||||||
|
- name: Make Gradlew Executable
|
||||||
|
run: chmod +x android/gradlew
|
||||||
|
|
||||||
|
- name: Inspect Build Environment
|
||||||
|
run: |
|
||||||
|
flutter --version
|
||||||
|
java -version
|
||||||
|
|
||||||
|
- name: Fetch Flutter Dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Run Code Analysis & Tests
|
||||||
|
run: |
|
||||||
|
flutter analyze
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
- name: Build Universal Release APK
|
||||||
|
run: flutter build apk --release
|
||||||
|
|
||||||
|
- name: Build Split-per-ABI Release APKs
|
||||||
|
run: flutter build apk --release --split-per-abi
|
||||||
|
|
||||||
|
- name: Organize Artifacts
|
||||||
|
run: |
|
||||||
|
mkdir -p release-apks
|
||||||
|
# Copy universal APK
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-release.apk release-apks/oggauer-gemeindetrommler-universal-release.apk
|
||||||
|
fi
|
||||||
|
# Copy split APKs
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-arm64-v8a-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk release-apks/oggauer-gemeindetrommler-arm64-v8a.apk
|
||||||
|
fi
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk release-apks/oggauer-gemeindetrommler-armeabi-v7a.apk
|
||||||
|
fi
|
||||||
|
if [ -f build/app/outputs/flutter-apk/app-x86_64-release.apk ]; then
|
||||||
|
cp build/app/outputs/flutter-apk/app-x86_64-release.apk release-apks/oggauer-gemeindetrommler-x86_64.apk
|
||||||
|
fi
|
||||||
|
echo "=== Generated APK Artifacts ==="
|
||||||
|
ls -lah release-apks/
|
||||||
|
|
||||||
|
- name: Upload APKs to Gitea Artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: oggauer-gemeindetrommler-apks
|
||||||
|
path: release-apks/*.apk
|
||||||
|
retention-days: 30
|
||||||
@@ -42,3 +42,5 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
/android/app/build/
|
||||||
|
.gradle/
|
||||||
|
|||||||
@@ -63,19 +63,50 @@ Basierend auf dem ursprünglichen Lastenheft von Thomas und den UI-Wireframes (`
|
|||||||
### Projektstruktur (`lib/`):
|
### Projektstruktur (`lib/`):
|
||||||
```text
|
```text
|
||||||
lib/
|
lib/
|
||||||
├── AddPage.dart # Erfassungsdialog für Beiträge, Mängel & Ideen (Upload, Crop)
|
├── firebase_options.dart # Firebase-Projektkonfiguration (Android & iOS)
|
||||||
├── DetailPage.dart # Detailansicht für einzelne Beiträge inkl. PDF-Export
|
├── main.dart # App-Einstiegspunkt, Firebase Init & MultiProvider
|
||||||
├── LoginPage.dart # (Fragment) E-Mail/Passwort-Loginmaske (nicht verdrahtet)
|
├── models/
|
||||||
├── register.dart # (Fragment) Registrierungsmaske (nicht verdrahtet)
|
│ └── post_item.dart # Typisiertes Datenmodell für News, Mängel & Ideen
|
||||||
├── UserDefinedList.dart # Universelle Listenanzeige, Firestore-Stream, Selektion & Sammel-PDF
|
├── screens/
|
||||||
├── anonym_aut.dart # AuthState Provider & einfacher anonymer Login-Screen
|
│ ├── add_issue_screen.dart # Mängelerfassung mit Straßenauswahl & bis zu 2 Fotos
|
||||||
├── firebase_options.dart # Firebase-Projektkonfiguration (Android & iOS)
|
│ ├── add_post_screen.dart # Universelle Erfassung für News & Bürgerideen
|
||||||
├── home.dart # Haupt-Scaffold mit BottomNavigationBar (4 Tabs)
|
│ ├── auth_dialog.dart # Anmelde-, Registrierungs- & Code-Freischaltungs-Dialog
|
||||||
└── main.dart # App-Einstiegspunkt, Firebase Init & MultiProvider
|
│ ├── contact_screen.dart # Bürgerforum-Kontaktformular & Anfragen
|
||||||
|
│ ├── detail_screen.dart # Detailansicht mit Metadaten & PDF-Einzelexport
|
||||||
|
│ ├── home_screen.dart # Haupt-Scaffold mit 5 Tabs (News, Mängel, Ideen, Kontakt, Info)
|
||||||
|
│ ├── info_screen.dart # Bürgerforum Leitbild, Notrufnummern & Account-Status
|
||||||
|
│ └── post_list_screen.dart # Universelle Listenansicht, Echtzeitsuche & PDF-Tabelle
|
||||||
|
└── services/
|
||||||
|
├── auth_service.dart # Hybrid-Auth (E-Mail/Passwort, Bürger-Code, Anonym)
|
||||||
|
├── firestore_service.dart# NoSQL CRUD & Kontaktanfragen
|
||||||
|
├── pdf_service.dart # PDF-Druckerzeugung (Listen & Einzelansichten)
|
||||||
|
└── storage_service.dart # Optimierter Bild-Upload (Querformat max 800x600)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🤖 CI/CD Pipeline (Gitea Actions)
|
||||||
|
|
||||||
|
Die App verfügt über eine vollautomatische Build-Pipeline für **Gitea Actions** (`.gitea/workflows/build-apk.yaml`):
|
||||||
|
|
||||||
|
### Funktionen der Pipeline:
|
||||||
|
- **Automatische Trigger:** Wird bei jedem `push` auf `main`, `master`, `refactor/**`, bei Git-Tags (`v*`) oder manuell im Webinterface (`workflow_dispatch`) ausgelöst.
|
||||||
|
- **Isolierte Build-Umgebung:** Nutzt das offizielle `ghcr.io/cirruslabs/flutter:3.19.3` Docker-Image mit vorinstalliertem Android SDK, Java 17 und Flutter.
|
||||||
|
- **Qualitätssicherung:** Führt automatisch `flutter analyze` und `flutter test` aus, bevor der Build startet.
|
||||||
|
- **Vollständige APK-Generierung:**
|
||||||
|
- `oggauer-gemeindetrommler-universal-release.apk` (Universelle Release-APK für alle Android-Geräte)
|
||||||
|
- `oggauer-gemeindetrommler-arm64-v8a.apk` (Für moderne 64-Bit Smartphones)
|
||||||
|
- `oggauer-gemeindetrommler-armeabi-v7a.apk` (Für ältere 32-Bit Smartphones)
|
||||||
|
- `oggauer-gemeindetrommler-x86_64.apk` (Für Emulatoren & ChromeOS)
|
||||||
|
- **Artifact-Upload:** Speichert die fertigen APKs als herunterladbare ZIP-Datei (`oggauer-gemeindetrommler-apks`) direkt im Gitea Run-Dashboard.
|
||||||
|
|
||||||
|
### APKs in Gitea herunterladen:
|
||||||
|
1. Im Gitea-Repository auf den Reiter **Aktionen** (*Actions*) klicken.
|
||||||
|
2. Den gewünschten Pipeline-Durchlauf auswählen.
|
||||||
|
3. Im Abschnitt **Artefakte** (*Artifacts*) das Paket `oggauer-gemeindetrommler-apks` herunterladen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🛠️ Einrichtung & Lokaler Start
|
## 🛠️ Einrichtung & Lokaler Start
|
||||||
|
|
||||||
### Voraussetzungen
|
### Voraussetzungen
|
||||||
@@ -92,31 +123,14 @@ flutter pub get
|
|||||||
# 2. Statische Code-Analyse ausführen
|
# 2. Statische Code-Analyse ausführen
|
||||||
flutter analyze
|
flutter analyze
|
||||||
|
|
||||||
# 3. App starten
|
# 3. Tests ausführen
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
# 4. App lokal starten
|
||||||
flutter run
|
flutter run
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Empfohlene Verbesserungen & Roadmap
|
|
||||||
|
|
||||||
Die Erstellung durch frühe KI-Modelle hat zu funktionalen Proof-of-Concepts geführt, weist jedoch typischen Refactoring-Bedarf auf:
|
|
||||||
|
|
||||||
1. **Code-Hygiene & Best Practices:**
|
|
||||||
- Umbenennung der Dateien nach Dart-Konvention (`snake_case`, z. B. `add_page.dart`, `detail_page.dart`).
|
|
||||||
- Behebung der `flutter analyze` Warnungen (Deprecations wie `enablePersistence`, `BuildContext` across async gaps, ungenutzte Imports).
|
|
||||||
- Saubere Abhängigkeitsdeklaration (`http` direkt in `pubspec.yaml` aufnehmen).
|
|
||||||
2. **Architektur & Wartbarkeit:**
|
|
||||||
- Trennung von UI und Business-Logik (Einführung von Repositories / Services für Firestore und Firebase Storage).
|
|
||||||
- Auslagerung der CPU-intensiven Bildverarbeitung (`image.decodeImage`) in Isolate (`compute`), um UI-Ruckler zu vermeiden.
|
|
||||||
3. **Vervollständigung der Fachanforderungen:**
|
|
||||||
- **Kontakt-Formular:** Umsetzung mit Pflichtfeldern und Mail-Trigger (z. B. via Firebase Extension `Trigger Email` oder Cloud Function).
|
|
||||||
- **Informationen / Impressum / Veranstaltungen:** Fünfter Tab gemäß Anforderung.
|
|
||||||
- **Mängelmeldung:** Dropdown für Straßenverzeichnis Oggau und Grundlage; Unterstützung von bis zu 2 Fotos im Querformat.
|
|
||||||
- **Volltextsuche:** Suchleiste / Suchsymbol in den Listenansichten.
|
|
||||||
- **Zugangskonzept:** Echtes Bürger-Passwort bzw. PIN-Schutz statt reinem anonymen Login.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📄 Lizenz & Urheberschaft
|
## 📄 Lizenz & Urheberschaft
|
||||||
Erstellt für die Marktgemeinde Oggau am Neusiedler See. Private Verwendung.
|
Entwickelt für das **Bürgerforum Oggau**. Private & gemeinnützige Verwendung.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,35 @@
|
|||||||
|
rules_version = '2';
|
||||||
|
service cloud.firestore {
|
||||||
|
match /databases/{database}/documents {
|
||||||
|
|
||||||
|
// News / Neuigkeiten: Öffentlich lesbar, Schreiben für angemeldete Nutzer
|
||||||
|
match /News/{document=**} {
|
||||||
|
allow read: if true;
|
||||||
|
allow write: if request.auth != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mängel & Anliegen: Öffentlich lesbar, Erstellen angemeldet, Löschen nur eigener Autor
|
||||||
|
match /Issues/{document} {
|
||||||
|
allow read: if true;
|
||||||
|
allow create: if request.auth != null;
|
||||||
|
allow update: if request.auth != null;
|
||||||
|
allow delete: if request.auth != null &&
|
||||||
|
(resource.data.author_uid == request.auth.uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bürgerforum / Ideen: Öffentlich lesbar, Erstellen angemeldet, Löschen eigener Autor
|
||||||
|
match /CitizensForum/{document} {
|
||||||
|
allow read: if true;
|
||||||
|
allow create: if request.auth != null;
|
||||||
|
allow update: if request.auth != null;
|
||||||
|
allow delete: if request.auth != null &&
|
||||||
|
(resource.data.author_uid == request.auth.uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kontakt-Nachrichten: Jeder kann einsenden, Lesen nur berechtigte Nutzer
|
||||||
|
match /ContactMessages/{document} {
|
||||||
|
allow create: if true;
|
||||||
|
allow read, update, delete: if request.auth != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,459 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../services/auth_service.dart';
|
||||||
|
|
||||||
|
class AuthDialog extends StatefulWidget {
|
||||||
|
const AuthDialog({super.key});
|
||||||
|
|
||||||
|
static Future<void> show(BuildContext context) async {
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => const AuthDialog(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AuthDialog> createState() => _AuthDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AuthDialogState extends State<AuthDialog>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late TabController _tabController;
|
||||||
|
|
||||||
|
// Login Controllers
|
||||||
|
final _loginEmailController = TextEditingController();
|
||||||
|
final _loginPasswordController = TextEditingController();
|
||||||
|
|
||||||
|
// Register Controllers
|
||||||
|
final _regNameController = TextEditingController();
|
||||||
|
final _regEmailController = TextEditingController();
|
||||||
|
final _regPasswordController = TextEditingController();
|
||||||
|
final _regConfirmPasswordController = TextEditingController();
|
||||||
|
|
||||||
|
// Code Controller
|
||||||
|
final _codeController = TextEditingController();
|
||||||
|
|
||||||
|
bool _isLoading = false;
|
||||||
|
String? _errorMessage;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tabController = TabController(length: 3, vsync: this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_tabController.dispose();
|
||||||
|
_loginEmailController.dispose();
|
||||||
|
_loginPasswordController.dispose();
|
||||||
|
_regNameController.dispose();
|
||||||
|
_regEmailController.dispose();
|
||||||
|
_regPasswordController.dispose();
|
||||||
|
_regConfirmPasswordController.dispose();
|
||||||
|
_codeController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleLogin() async {
|
||||||
|
final email = _loginEmailController.text.trim();
|
||||||
|
final password = _loginPasswordController.text;
|
||||||
|
|
||||||
|
if (email.isEmpty || password.isEmpty) {
|
||||||
|
setState(() => _errorMessage = 'Bitte E-Mail und Passwort eingeben.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_errorMessage = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
final auth = Provider.of<AuthService>(context, listen: false);
|
||||||
|
final error = await auth.signInWithEmail(email, password);
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
|
||||||
|
if (error == null) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Erfolgreich angemeldet!'),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setState(() => _errorMessage = error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleRegister() async {
|
||||||
|
final name = _regNameController.text.trim();
|
||||||
|
final email = _regEmailController.text.trim();
|
||||||
|
final password = _regPasswordController.text;
|
||||||
|
final confirm = _regConfirmPasswordController.text;
|
||||||
|
|
||||||
|
if (name.isEmpty || email.isEmpty || password.isEmpty) {
|
||||||
|
setState(() => _errorMessage = 'Bitte alle Pflichtfelder ausfüllen.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password != confirm) {
|
||||||
|
setState(() => _errorMessage = 'Die Passwörter stimmen nicht überein.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password.length < 6) {
|
||||||
|
setState(
|
||||||
|
() => _errorMessage = 'Das Passwort muss mindestens 6 Zeichen lang sein.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_errorMessage = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
final auth = Provider.of<AuthService>(context, listen: false);
|
||||||
|
final error = await auth.signUpWithEmail(
|
||||||
|
email: email,
|
||||||
|
password: password,
|
||||||
|
name: name,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
|
||||||
|
if (error == null) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Konto erfolgreich erstellt! Willkommen im Bürgerforum.'),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setState(() => _errorMessage = error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleCodeUnlock() async {
|
||||||
|
final code = _codeController.text.trim();
|
||||||
|
if (code.isEmpty) {
|
||||||
|
setState(() => _errorMessage = 'Bitte den Zugangscode eingeben.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_errorMessage = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
final auth = Provider.of<AuthService>(context, listen: false);
|
||||||
|
final success = await auth.verifyCommunityCode(code);
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Bürgerzugang freigeschaltet!'),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setState(() => _errorMessage =
|
||||||
|
'Ungültiger Zugangscode. Bitte wende dich an das Bürgerforum.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showPasswordResetDialog() {
|
||||||
|
final resetEmailController = TextEditingController(
|
||||||
|
text: _loginEmailController.text,
|
||||||
|
);
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: const Text('Passwort zurücksetzen'),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Gib deine E-Mail-Adresse ein. Wir senden dir einen Link, mit dem du ein neues Passwort festlegen kannst.',
|
||||||
|
style: TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: resetEmailController,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'E-Mail-Adresse',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx),
|
||||||
|
child: const Text('Abbrechen'),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final email = resetEmailController.text.trim();
|
||||||
|
if (email.isEmpty) return;
|
||||||
|
final auth = Provider.of<AuthService>(context, listen: false);
|
||||||
|
final messenger = ScaffoldMessenger.of(context);
|
||||||
|
final navigator = Navigator.of(ctx);
|
||||||
|
final err = await auth.sendPasswordReset(email);
|
||||||
|
if (!mounted) return;
|
||||||
|
navigator.pop();
|
||||||
|
messenger.showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(err ?? 'E-Mail zum Zurücksetzen wurde versendet!'),
|
||||||
|
backgroundColor: err == null ? Colors.green : Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Link senden'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
|
insetPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 420),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Bürgerforum Oggau',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
labelColor: Colors.blue.shade800,
|
||||||
|
indicatorColor: Colors.blue.shade800,
|
||||||
|
tabs: const [
|
||||||
|
Tab(text: 'Anmelden'),
|
||||||
|
Tab(text: 'Registrieren'),
|
||||||
|
Tab(text: 'Code-Login'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (_errorMessage != null) ...[
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.red.shade50,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: Colors.red.shade200),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error_outline,
|
||||||
|
color: Colors.red, size: 18),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
_errorMessage!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12, color: Colors.red.shade900),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Flexible(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 280,
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
// Tab 1: Login
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _loginEmailController,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'E-Mail-Adresse',
|
||||||
|
prefixIcon: Icon(Icons.email_outlined),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: _loginPasswordController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Passwort',
|
||||||
|
prefixIcon: Icon(Icons.lock_outline),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: _showPasswordResetDialog,
|
||||||
|
child: const Text(
|
||||||
|
'Passwort vergessen?',
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _isLoading ? null : _handleLogin,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
),
|
||||||
|
child: _isLoading
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: const Text('Anmelden'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// Tab 2: Registrierung
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _regNameController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Name / Vorname',
|
||||||
|
prefixIcon: Icon(Icons.person_outline),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
controller: _regEmailController,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'E-Mail-Adresse',
|
||||||
|
prefixIcon: Icon(Icons.email_outlined),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
controller: _regPasswordController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Passwort (mind. 6 Zeichen)',
|
||||||
|
prefixIcon: Icon(Icons.lock_outline),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
controller: _regConfirmPasswordController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Passwort bestätigen',
|
||||||
|
prefixIcon: Icon(Icons.lock_outline),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _isLoading ? null : _handleRegister,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
),
|
||||||
|
child: _isLoading
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: const Text('Konto erstellen'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// Tab 3: Bürger-Code
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Du möchtest kein persönliches Konto anlegen? Gib einfach den Zugangscode des Bürgerforums ein, um sofort Mängel und Ideen melden zu können.',
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 13, color: Colors.black87),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextField(
|
||||||
|
controller: _codeController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Bürger-Zugangscode',
|
||||||
|
prefixIcon: Icon(Icons.key_outlined),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
hintText: 'z.B. oggau',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _isLoading ? null : _handleCodeUnlock,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
),
|
||||||
|
child: _isLoading
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: const Text('Freischalten'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,8 +83,12 @@ class _ContactScreenState extends State<ContactScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Kontakt Bürgerforum'),
|
||||||
|
centerTitle: true,
|
||||||
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -102,7 +106,7 @@ class _ContactScreenState extends State<ContactScreen> {
|
|||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Hier können Sie auch ohne Anmeldung direkt mit der Bürgerliste / Gemeindevertretung in Kontakt treten.',
|
'Hier kannst du direkt mit dem Bürgerforum Oggau in Kontakt treten. Wir freuen uns über deine Anregungen und Fragen!',
|
||||||
style: TextStyle(fontSize: 13),
|
style: TextStyle(fontSize: 13),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
final List<Widget> _pages = const [
|
final List<Widget> _pages = const [
|
||||||
PostListScreen(
|
PostListScreen(
|
||||||
collectionName: 'News',
|
collectionName: 'News',
|
||||||
title: 'Nachrichten & Aktuelles',
|
title: 'Bürgerforum Aktuelles',
|
||||||
),
|
),
|
||||||
PostListScreen(
|
PostListScreen(
|
||||||
collectionName: 'Issues',
|
collectionName: 'Issues',
|
||||||
title: 'Mängel & Bürgeranliegen',
|
title: 'Mängel & Anliegen',
|
||||||
),
|
),
|
||||||
PostListScreen(
|
PostListScreen(
|
||||||
collectionName: 'CitizensForum',
|
collectionName: 'CitizensForum',
|
||||||
@@ -75,7 +75,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Icons.info_outline),
|
icon: Icon(Icons.info_outline),
|
||||||
activeIcon: Icon(Icons.info),
|
activeIcon: Icon(Icons.info),
|
||||||
label: 'Informationen',
|
label: 'Bürgerforum',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
+207
-148
@@ -1,140 +1,210 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../services/auth_service.dart';
|
import '../services/auth_service.dart';
|
||||||
|
import 'auth_dialog.dart';
|
||||||
|
|
||||||
class InfoScreen extends StatefulWidget {
|
class InfoScreen extends StatelessWidget {
|
||||||
const InfoScreen({super.key});
|
const InfoScreen({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<InfoScreen> createState() => _InfoScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InfoScreenState extends State<InfoScreen> {
|
|
||||||
final TextEditingController _codeController = TextEditingController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_codeController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showUnlockDialog(BuildContext context) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (dialogCtx) => AlertDialog(
|
|
||||||
title: const Text('Gemeinde-Zugang freischalten'),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'Geben Sie das Passwort bzw. den Zugangscode der Marktgemeinde Oggau ein, um Mängel zu melden und im Bürgerforum mitzuwirken.',
|
|
||||||
style: TextStyle(fontSize: 13),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
TextField(
|
|
||||||
controller: _codeController,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Gemeinde-Passwort',
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
hintText: 'z.B. oggau',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(dialogCtx),
|
|
||||||
child: const Text('Abbrechen'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final auth = Provider.of<AuthService>(context, listen: false);
|
|
||||||
final success =
|
|
||||||
await auth.verifyCommunityCode(_codeController.text);
|
|
||||||
if (!dialogCtx.mounted) return;
|
|
||||||
Navigator.pop(dialogCtx);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(success
|
|
||||||
? 'Zugang erfolgreich freigeschaltet!'
|
|
||||||
: 'Ungültiges Passwort. Bitte kontaktieren Sie das Gemeindeamt.'),
|
|
||||||
backgroundColor: success ? Colors.green : Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Freischalten'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final auth = Provider.of<AuthService>(context);
|
final auth = Provider.of<AuthService>(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Bürgerforum Oggau'),
|
||||||
|
centerTitle: true,
|
||||||
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||||
children: [
|
children: [
|
||||||
// Community Access Card
|
// Bürgerforum Logo & Branding Header
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/logo.png',
|
||||||
|
height: 72,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text(
|
||||||
|
'Bürgerforum Oggau',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
'Unabhängige Bürgerliste für Oggau am Neusiedler See',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey.shade700),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// Bürgerforum Access & Account Card
|
||||||
Card(
|
Card(
|
||||||
color: auth.isCommunityUnlocked ? Colors.green.shade50 : Colors.blue.shade50,
|
color: auth.isRegisteredUser
|
||||||
|
? Colors.green.shade50
|
||||||
|
: auth.isCommunityUnlocked
|
||||||
|
? Colors.teal.shade50
|
||||||
|
: Colors.blue.shade50,
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(14.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
auth.isRegisteredUser
|
||||||
|
? Icons.account_circle
|
||||||
|
: auth.isCommunityUnlocked
|
||||||
|
? Icons.verified_user
|
||||||
|
: Icons.lock_outline,
|
||||||
|
color: auth.isRegisteredUser
|
||||||
|
? Colors.green.shade700
|
||||||
|
: auth.isCommunityUnlocked
|
||||||
|
? Colors.teal.shade800
|
||||||
|
: Colors.blue.shade800,
|
||||||
|
size: 36,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
auth.isRegisteredUser
|
||||||
|
? (auth.displayName?.isNotEmpty == true
|
||||||
|
? auth.displayName!
|
||||||
|
: 'Bürger-Konto')
|
||||||
|
: auth.isCommunityUnlocked
|
||||||
|
? 'Bürgerzugang: Aktiv (Code)'
|
||||||
|
: 'Gastmodus (Nur Lesen)',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold, fontSize: 15),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
auth.isRegisteredUser
|
||||||
|
? auth.email ?? 'Angemeldet'
|
||||||
|
: auth.isCommunityUnlocked
|
||||||
|
? 'Mängel & Ideen freigeschaltet'
|
||||||
|
: 'Anmelden oder Code eingeben zum Mitwirken.',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12, color: Colors.grey.shade700),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 14, vertical: 8),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (auth.isRegisteredUser || auth.isCommunityUnlocked) {
|
||||||
|
auth.lockCommunityAccess();
|
||||||
|
} else {
|
||||||
|
AuthDialog.show(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
(auth.isRegisteredUser || auth.isCommunityUnlocked)
|
||||||
|
? 'Abmelden'
|
||||||
|
: 'Anmelden',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (!auth.isRegisteredUser && auth.isCommunityUnlocked) ...[
|
||||||
|
const Divider(height: 16),
|
||||||
|
InkWell(
|
||||||
|
onTap: () => AuthDialog.show(context),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.person_add,
|
||||||
|
size: 16, color: Colors.blue.shade800),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
'Persönliches Konto anlegen für dauerhaften Login',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.blue.shade800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
|
// About Bürgerforum Oggau
|
||||||
|
Card(
|
||||||
|
elevation: 1.5,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Row(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Row(
|
||||||
auth.isCommunityUnlocked
|
children: [
|
||||||
? Icons.verified_user
|
Icon(Icons.campaign, color: Colors.blue.shade800, size: 24),
|
||||||
: Icons.lock_outline,
|
const SizedBox(width: 8),
|
||||||
color: auth.isCommunityUnlocked ? Colors.green : Colors.blue,
|
const Text(
|
||||||
size: 36,
|
'Über das Bürgerforum Oggau',
|
||||||
|
style: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(height: 10),
|
||||||
Expanded(
|
const Text(
|
||||||
child: Column(
|
'Das Bürgerforum Oggau ist eine unabhängige Bürgerliste für unsere Marktgemeinde Oggau am Neusiedler See.\n\n'
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
'Wir stehen für Bürgernähe, Transparenz und eine zukunftsorientierte Gemeindepolitik. '
|
||||||
children: [
|
'Mit dieser App (unserem digitalen „Gemeindetrommler“) wollen wir allen Bürgerinnen und Bürgern eine unkomplizierte Möglichkeit geben, Mängel im Ort aufzuzeigen, Ideen einzubringen und sich zu informieren.',
|
||||||
Text(
|
style: TextStyle(fontSize: 13, height: 1.45),
|
||||||
auth.isCommunityUnlocked
|
|
||||||
? 'Bürgerzugang: Aktiv'
|
|
||||||
: 'Gastmodus (Nur Lesen)',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold, fontSize: 16),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
auth.isCommunityUnlocked
|
|
||||||
? 'Sie können Mängel und Ideen einreichen.'
|
|
||||||
: 'Gemeinde-Passwort eingeben zum Freischalten.',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12, color: Colors.grey.shade700),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
const SizedBox(height: 12),
|
||||||
onPressed: () {
|
const Divider(),
|
||||||
if (auth.isCommunityUnlocked) {
|
const SizedBox(height: 8),
|
||||||
auth.lockCommunityAccess();
|
Row(
|
||||||
} else {
|
children: [
|
||||||
_showUnlockDialog(context);
|
const Icon(Icons.group, size: 16, color: Colors.grey),
|
||||||
}
|
const SizedBox(width: 8),
|
||||||
},
|
Text(
|
||||||
child: Text(auth.isCommunityUnlocked ? 'Sperren' : 'Anmelden'),
|
'Gemeindevertretung & Team Bürgerforum',
|
||||||
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: Colors.grey.shade800),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// Gemeinde Info Header
|
// Gemeinde Bürgerservice (Nützliche Kontakte)
|
||||||
Card(
|
Card(
|
||||||
elevation: 2,
|
elevation: 1,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
@@ -142,33 +212,29 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Marktgemeinde Oggau am Neusiedler See',
|
'Gemeindeamt & Bürgerservice Oggau',
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text('Hauptstraße 52, 7063 Oggau'),
|
Text('Adresse: Hauptstraße 52, 7063 Oggau', style: TextStyle(fontSize: 13)),
|
||||||
Text('Telefon: +43 2685 7201'),
|
Text('Telefon: +43 2685 7201', style: TextStyle(fontSize: 13)),
|
||||||
Text('E-Mail: post@oggau.bgld.gv.at'),
|
Text('Web: www.oggau.at', style: TextStyle(fontSize: 13)),
|
||||||
Text('Web: www.oggau.at'),
|
|
||||||
SizedBox(height: 12),
|
|
||||||
Divider(),
|
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Parteienverkehr / Öffnungszeiten:',
|
'Öffnungszeiten Gemeindeamt:',
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
SizedBox(height: 4),
|
Text('Mo – Fr: 08:00 – 12:00 Uhr | Di zusätzlich: 13:00 – 17:00 Uhr',
|
||||||
Text('Montag bis Freitag: 08:00 – 12:00 Uhr'),
|
style: TextStyle(fontSize: 12)),
|
||||||
Text('Dienstag zusätzlich: 13:00 – 17:00 Uhr'),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// Notrufnummern
|
// Wichtige Notrufnummern
|
||||||
Card(
|
Card(
|
||||||
elevation: 2,
|
elevation: 1,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
@@ -177,9 +243,9 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Wichtige Notrufnummern',
|
'Wichtige Notrufnummern',
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.red),
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold, color: Colors.red),
|
||||||
),
|
),
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 10),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -187,7 +253,7 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
Text('122', style: TextStyle(fontWeight: FontWeight.bold)),
|
Text('122', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(height: 16),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -195,7 +261,7 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
Text('133', style: TextStyle(fontWeight: FontWeight.bold)),
|
Text('133', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(height: 16),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -203,7 +269,7 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
Text('144', style: TextStyle(fontWeight: FontWeight.bold)),
|
Text('144', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(height: 16),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -211,19 +277,11 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
Text('112', style: TextStyle(fontWeight: FontWeight.bold)),
|
Text('112', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text('Ärztefunkdienst'),
|
|
||||||
Text('141', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// Impressum
|
// Impressum
|
||||||
Card(
|
Card(
|
||||||
@@ -235,22 +293,23 @@ class _InfoScreenState extends State<InfoScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Impressum & Rechtliches',
|
'Impressum',
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 6),
|
||||||
Text(
|
Text(
|
||||||
'Medieninhaber & Herausgeber:\n'
|
'Medieninhaber & Herausgeber:\n'
|
||||||
'Marktgemeinde Oggau am Neusiedler See\n'
|
'Bürgerforum Oggau (Unabhängige Bürgerliste Oggau)\n'
|
||||||
'Hauptstraße 52, A-7063 Oggau\n\n'
|
'7063 Oggau am Neusiedler See\n\n'
|
||||||
'Erstellt als Gemeinde-Informationssystem für Bürgerinnen und Bürger.\n'
|
'Zweck der App:\n'
|
||||||
'Alle Rechte vorbehalten.',
|
'Informations- und Mitmach-Plattform für Bürgerinnen und Bürger der Marktgemeinde Oggau am Neusiedler See.',
|
||||||
style: TextStyle(fontSize: 12, color: Colors.black87),
|
style: TextStyle(fontSize: 12, color: Colors.black87, height: 1.4),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import '../services/pdf_service.dart';
|
|||||||
import '../services/storage_service.dart';
|
import '../services/storage_service.dart';
|
||||||
import 'add_issue_screen.dart';
|
import 'add_issue_screen.dart';
|
||||||
import 'add_post_screen.dart';
|
import 'add_post_screen.dart';
|
||||||
|
import 'auth_dialog.dart';
|
||||||
import 'detail_screen.dart';
|
import 'detail_screen.dart';
|
||||||
|
|
||||||
class PostListScreen extends StatefulWidget {
|
class PostListScreen extends StatefulWidget {
|
||||||
@@ -75,19 +76,15 @@ class _PostListScreenState extends State<PostListScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddNewPressed(BuildContext context) {
|
Future<void> _onAddNewPressed() async {
|
||||||
final auth = Provider.of<AuthService>(context, listen: false);
|
final auth = Provider.of<AuthService>(context, listen: false);
|
||||||
|
|
||||||
if (!auth.isCommunityUnlocked && !auth.isAuthenticated) {
|
if (!auth.isCommunityUnlocked && !auth.isAuthenticated) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
await AuthDialog.show(context);
|
||||||
const SnackBar(
|
if (!mounted) return;
|
||||||
content: Text(
|
if (!auth.isCommunityUnlocked && !auth.isAuthenticated) {
|
||||||
'Bitte schalten Sie den Zugang unter "Informationen" mit dem Gemeinde-Passwort frei.',
|
return;
|
||||||
),
|
}
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearSelection();
|
_clearSelection();
|
||||||
@@ -124,13 +121,32 @@ class _PostListScreenState extends State<PostListScreen> {
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
style: const TextStyle(color: Colors.black87),
|
style: const TextStyle(color: Colors.black87),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Suche nach ${widget.title}...',
|
hintText: 'Suche in ${widget.title}...',
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
hintStyle: TextStyle(color: Colors.grey.shade600),
|
hintStyle: TextStyle(color: Colors.grey.shade600),
|
||||||
),
|
),
|
||||||
onChanged: (val) => setState(() => _searchQuery = val.trim()),
|
onChanged: (val) => setState(() => _searchQuery = val.trim()),
|
||||||
)
|
)
|
||||||
: Text(widget.title),
|
: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/logo.png',
|
||||||
|
height: 26,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
widget.title,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(_isSearchActive ? Icons.close : Icons.search),
|
icon: Icon(_isSearchActive ? Icons.close : Icons.search),
|
||||||
@@ -394,7 +410,7 @@ class _PostListScreenState extends State<PostListScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () => _onAddNewPressed(context),
|
onPressed: _onAddNewPressed,
|
||||||
tooltip: 'Neuen Eintrag erstellen',
|
tooltip: 'Neuen Eintrag erstellen',
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ class AuthService extends ChangeNotifier {
|
|||||||
|
|
||||||
User? get user => _user;
|
User? get user => _user;
|
||||||
bool get isAuthenticated => _user != null;
|
bool get isAuthenticated => _user != null;
|
||||||
bool get isCommunityUnlocked => _isCommunityUnlocked;
|
bool get isAnonymous => _user?.isAnonymous ?? true;
|
||||||
|
bool get isRegisteredUser => _user != null && !_user!.isAnonymous;
|
||||||
|
bool get isCommunityUnlocked => _isCommunityUnlocked || isRegisteredUser;
|
||||||
|
String? get email => _user?.email;
|
||||||
|
String? get displayName => _user?.displayName;
|
||||||
|
|
||||||
AuthService() {
|
AuthService() {
|
||||||
_initAuth();
|
_initAuth();
|
||||||
@@ -27,26 +31,30 @@ class AuthService extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Automatically ensure anonymous login if unlocked
|
|
||||||
if (_user == null && _isCommunityUnlocked) {
|
if (_user == null && _isCommunityUnlocked) {
|
||||||
await signInAnonymously();
|
await signInAnonymously();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Verifies community access code
|
||||||
Future<bool> verifyCommunityCode(String enteredCode) async {
|
Future<bool> verifyCommunityCode(String enteredCode) async {
|
||||||
final cleanCode = enteredCode.trim().toLowerCase();
|
final cleanCode = enteredCode.trim().toLowerCase();
|
||||||
// Accept default code 'oggau' or any custom community password
|
if (cleanCode == defaultCommunityCode ||
|
||||||
if (cleanCode == defaultCommunityCode || cleanCode == 'oggau2024' || cleanCode == 'oggau7063') {
|
cleanCode == 'oggau2024' ||
|
||||||
|
cleanCode == 'oggau7063') {
|
||||||
_isCommunityUnlocked = true;
|
_isCommunityUnlocked = true;
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setBool(_prefKeyUnlocked, true);
|
await prefs.setBool(_prefKeyUnlocked, true);
|
||||||
await signInAnonymously();
|
if (_user == null) {
|
||||||
|
await signInAnonymously();
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Lock community access and log out
|
||||||
Future<void> lockCommunityAccess() async {
|
Future<void> lockCommunityAccess() async {
|
||||||
_isCommunityUnlocked = false;
|
_isCommunityUnlocked = false;
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@@ -55,6 +63,60 @@ class AuthService extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sign in with Email and Password
|
||||||
|
Future<String?> signInWithEmail(String email, String password) async {
|
||||||
|
try {
|
||||||
|
final credential = await _auth.signInWithEmailAndPassword(
|
||||||
|
email: email.trim(),
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
|
_user = credential.user;
|
||||||
|
notifyListeners();
|
||||||
|
return null; // success
|
||||||
|
} on FirebaseAuthException catch (e) {
|
||||||
|
return _getLocalizedErrorMessage(e.code);
|
||||||
|
} catch (e) {
|
||||||
|
return 'Ein unerwarteter Fehler ist aufgetreten: $e';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sign up with Email, Password, and Full Name
|
||||||
|
Future<String?> signUpWithEmail({
|
||||||
|
required String email,
|
||||||
|
required String password,
|
||||||
|
required String name,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final credential = await _auth.createUserWithEmailAndPassword(
|
||||||
|
email: email.trim(),
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
|
_user = credential.user;
|
||||||
|
if (_user != null && name.isNotEmpty) {
|
||||||
|
await _user!.updateDisplayName(name.trim());
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
return null; // success
|
||||||
|
} on FirebaseAuthException catch (e) {
|
||||||
|
return _getLocalizedErrorMessage(e.code);
|
||||||
|
} catch (e) {
|
||||||
|
return 'Ein unerwarteter Fehler ist aufgetreten: $e';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send password reset email
|
||||||
|
Future<String?> sendPasswordReset(String email) async {
|
||||||
|
try {
|
||||||
|
await _auth.sendPasswordResetEmail(email: email.trim());
|
||||||
|
return null; // success
|
||||||
|
} on FirebaseAuthException catch (e) {
|
||||||
|
return _getLocalizedErrorMessage(e.code);
|
||||||
|
} catch (e) {
|
||||||
|
return 'Fehler beim Senden der E-Mail: $e';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Anonymous login
|
||||||
Future<void> signInAnonymously() async {
|
Future<void> signInAnonymously() async {
|
||||||
try {
|
try {
|
||||||
await _auth.signInAnonymously();
|
await _auth.signInAnonymously();
|
||||||
@@ -65,6 +127,7 @@ class AuthService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sign out
|
||||||
Future<void> signOut() async {
|
Future<void> signOut() async {
|
||||||
try {
|
try {
|
||||||
await _auth.signOut();
|
await _auth.signOut();
|
||||||
@@ -74,4 +137,26 @@ class AuthService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getLocalizedErrorMessage(String code) {
|
||||||
|
switch (code) {
|
||||||
|
case 'user-not-found':
|
||||||
|
return 'Kein Benutzer mit dieser E-Mail-Adresse gefunden.';
|
||||||
|
case 'wrong-password':
|
||||||
|
case 'invalid-credential':
|
||||||
|
return 'Falsches Passwort oder ungültige Anmeldedaten.';
|
||||||
|
case 'email-already-in-use':
|
||||||
|
return 'Diese E-Mail-Adresse wird bereits für ein Konto verwendet.';
|
||||||
|
case 'invalid-email':
|
||||||
|
return 'Bitte gib eine gültige E-Mail-Adresse ein.';
|
||||||
|
case 'weak-password':
|
||||||
|
return 'Das Passwort ist zu schwach (mindestens 6 Zeichen erforderlich).';
|
||||||
|
case 'too-many-requests':
|
||||||
|
return 'Zu viele fehlgeschlagene Versuche. Bitte warte kurz.';
|
||||||
|
case 'network-request-failed':
|
||||||
|
return 'Keine Internetverbindung vorhanden.';
|
||||||
|
default:
|
||||||
|
return 'Authentifizierungsfehler ($code).';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -78,10 +78,8 @@ flutter:
|
|||||||
# the material Icons class.
|
# the material Icons class.
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
assets:
|
||||||
# assets:
|
- assets/images/
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
rules_version = '2';
|
||||||
|
service firebase.storage {
|
||||||
|
match /b/{bucket}/o {
|
||||||
|
|
||||||
|
// Fotos von News, Mängeln und Ideen
|
||||||
|
match /{collection}/{userId}/{fileName} {
|
||||||
|
// Jeder darf Bilder in der App laden/ansehen
|
||||||
|
allow read: if true;
|
||||||
|
|
||||||
|
// Nur angemeldete Nutzer dürfen Fotos hochladen (max. 10 MB, nur Bilder)
|
||||||
|
allow create, update: if request.auth != null
|
||||||
|
&& request.resource.size < 10 * 1024 * 1024
|
||||||
|
&& request.resource.contentType.matches('image/.*');
|
||||||
|
|
||||||
|
// Nur der Verfasser (oder berechtigte Nutzer) darf sein Foto löschen
|
||||||
|
allow delete: if request.auth != null && request.auth.uid == userId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user