PIN PUUUUUSH
Zhe Pin lautet: 091142069 (very common pin, dont ask why)
This commit is contained in:
+8
-11
@@ -8,25 +8,22 @@ import 'package:mensaapp/providers/serviceProvider.dart';
|
||||
import 'package:mensaapp/providers/spaceProvider.dart';
|
||||
import 'package:mensaapp/providers/spezielleErnaehrungProvider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'dart:async';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
print(prefs.getString('supabase-ip'));
|
||||
var backendIp = prefs.getString('supabase-ip');
|
||||
if (backendIp != ''){
|
||||
await Supabase.initialize(
|
||||
url: "http://192.168.2.229:8000",
|
||||
anonKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",
|
||||
url: "http://$backendIp:8000",
|
||||
anonKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",
|
||||
);
|
||||
|
||||
var supabase = Supabase.instance.client;
|
||||
|
||||
/*
|
||||
var test = await supabase.from('flutter').insert(
|
||||
{"rating": {"huhu" : "Fuuuuck uuuuuu if this works"}}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class DatabaseService {
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary),
|
||||
child: Text("Abbrechen"),
|
||||
child: Text("Überarbeiten"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: allUnrated
|
||||
|
||||
+131
-6
@@ -3,7 +3,7 @@ import 'package:google_nav_bar/google_nav_bar.dart';
|
||||
import 'package:mensaapp/modules/databaseService.dart';
|
||||
import 'package:mensaapp/providers/spaceProvider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import '../providers/ambienteProvider.dart';
|
||||
import '../providers/anmerkungProvider.dart';
|
||||
import '../providers/essenProvider.dart';
|
||||
@@ -11,6 +11,9 @@ import '../providers/languageProvider.dart';
|
||||
import '../providers/pageProvider.dart';
|
||||
import '../providers/serviceProvider.dart';
|
||||
import '../providers/spezielleErnaehrungProvider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:restart_app/restart_app.dart';
|
||||
|
||||
|
||||
class SpaceRate extends StatelessWidget {
|
||||
const SpaceRate({super.key});
|
||||
@@ -80,20 +83,142 @@ class SpaceRate extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void change_backend_ip(BuildContext context) {
|
||||
final TextEditingController _ipController = TextEditingController();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
title: Text("Backend-IP ändern"),
|
||||
content: TextField(
|
||||
controller: _ipController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true), // IP-Format unterstützen
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Neue Backend-IP (z. B. 192.168.1.1)',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final newIp = _ipController.text;
|
||||
|
||||
if (newIp.isEmpty) {
|
||||
// Falls das Feld leer ist, gib eine Warnung aus
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Die IP-Adresse darf nicht leer sein!")),
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Speichere die neue IP in den Shared Preferences
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('supabase-ip', newIp);
|
||||
|
||||
// Hole die neue IP und initialisiere die Supabase-Verbindung neu
|
||||
|
||||
Restart.restartApp();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: Text("IP Ändern"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Dialog schließen
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: Text("Abbrechen"),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void enter_pin(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
final TextEditingController _pinController = TextEditingController();
|
||||
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
content: TextField(
|
||||
controller: _pinController,
|
||||
obscureText: true, // PIN als Passwort maskieren
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'PIN',
|
||||
counterText: '', // Entfernt die Zeichenanzahl-Anzeige
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (_pinController.text == '091142069') {
|
||||
// Wenn die PIN korrekt ist
|
||||
Navigator.of(context).pop(); // Dialog schließen
|
||||
change_backend_ip(context); // Aktion ausführen
|
||||
} else {
|
||||
// Wenn die PIN falsch ist, Fehler anzeigen
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Falsche PIN!"),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: Text("Absenden"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Schließt den Dialog
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: Text("Schließen"),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<LanguageProvider>(builder: (context, languageProvider, x) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
leading: GestureDetector(
|
||||
onTap: () {
|
||||
_showDeleteDialog(context); // Kurzer Klick
|
||||
},
|
||||
onLongPress: () async {
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
enter_pin(context); // Langer Klick
|
||||
},
|
||||
child: Icon(
|
||||
Icons.home_rounded,
|
||||
size: 36,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
onPressed: () {
|
||||
_showDeleteDialog(context);
|
||||
},
|
||||
),
|
||||
title: Consumer<PageProvider>(
|
||||
// Consumer verwenden, um den dynamischen Titel anzuzeigen
|
||||
|
||||
Reference in New Issue
Block a user