Anon Key UI

+ Kein Essen heute Meldung, wenn kein Essen an dem Tag verfügbar ist
This commit is contained in:
Jonas Braus
2025-03-08 16:26:34 +01:00
parent 5cc64cedc8
commit 0ca6d62dd1
132 changed files with 19344 additions and 58 deletions
+2 -1
View File
@@ -19,11 +19,12 @@ void main() async {
var prefs = await SharedPreferences.getInstance();
print(prefs.getString('supabase-ip'));
var backendIp = prefs.getString('supabase-ip');
var anonKey = prefs.getString("anon-key");
await startKioskMode();
if (backendIp != ''){
await Supabase.initialize(
url: "$backendIp",
anonKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImlleWl2aHZ6a2Vjc2JscWF5bHNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDEwMTUzMTYsImV4cCI6MjA1NjU5MTMxNn0.hf18LiI2zZRTypUCkm-Ksbj3y1krGyVIw5OzUbgCG0Y",
anonKey: "$anonKey",
);
}
+2 -1
View File
@@ -53,7 +53,8 @@ class PageEssenSelect extends StatelessWidget {
onPressed: () {
Provider.of<PageProvider>(context, listen: false).setSelectedEssen(i + 1, "Essen ${i + 1}: ${menus[i]}");
},
)
),
menus.length > 0 ? Container() : Text("Kein Essen heute!", style: TextStyle(fontSize: 60, color: Colors.black),)
],
),
),
+29 -8
View File
@@ -84,6 +84,8 @@ class SpaceRate extends StatelessWidget {
void change_backend_ip(BuildContext context) {
final TextEditingController _ipController = TextEditingController();
String anonkeyInput = "";
showDialog(
context: context,
builder: (BuildContext context) {
@@ -91,12 +93,28 @@ class SpaceRate extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
title: Text("Backend-IP ändern"),
content: TextField(
controller: _ipController, // IP-Format unterstützen
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Neue Backend-IP (z. B. 192.168.1.1)',
title: Text("Backend-Domain ändern"),
content: Container(
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 20,
children: [
TextField(
controller: _ipController, // IP-Format unterstützen
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Neue Backend-Domain (z. B. 192.168.1.1)',
),
),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Neuer Anon Key',
),
onChanged: (inputText) => anonkeyInput = inputText,
)
],
),
),
actions: [
@@ -104,17 +122,20 @@ class SpaceRate extends StatelessWidget {
onPressed: () async {
final newIp = _ipController.text;
if (newIp.isEmpty) {
if (newIp.isEmpty || anonkeyInput.isEmpty) {
// Falls das Feld leer ist, gib eine Warnung aus
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Die IP-Adresse darf nicht leer sein!")),
content: Text("Bitte Domain & Anon angeben!")),
);
return;
}
// Speichere die neue IP in den Shared Preferences
final prefs = await SharedPreferences.getInstance();
await prefs.setString('supabase-ip', newIp);
await prefs.setString("anon-key", anonkeyInput);
print(anonkeyInput);
// Hole die neue IP und initialisiere die Supabase-Verbindung neu