Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
removed all non working functionallity because of api changes and new…
Browse files Browse the repository at this point in the history
… restrictions
  • Loading branch information
Kirari04 committed Sep 1, 2023
1 parent bafce9b commit cd52d07
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 179 deletions.
7 changes: 7 additions & 0 deletions lib/bbw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ class _BBWPageState extends State<BBWPage> {
),
)
: ListView(children: [
Container(
padding: const EdgeInsets.only(left: 20, right: 20),
child: const Text(
"BBW Stundenplan aller Klassen.",
style: TextStyle(color: Colors.white),
),
),
Container(
padding: const EdgeInsets.only(left: 20, right: 20),
child: const Text(
Expand Down
2 changes: 1 addition & 1 deletion lib/data_seed.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

class DataSeed {
String title = "2I Stundenplan";
String title = "Intranet Stundenplan";

String api = "https://kbw.senpai.one/api/api.php";
String teacherApi = "https://kbw.senpai.one/api/teacher.php?teacher=";
Expand Down
4 changes: 2 additions & 2 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _HomePageState extends State<HomePage> {
});

//update cache only if loggedin
if (username != null && password != null) {
if (username != null && password != null && school != null) {
updateApiData(prefs, apiOldData);
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ class _HomePageState extends State<HomePage> {
.toUpperCase();
return ElevatedButton(
onPressed: () {
openTeacher(teacherId!, teachersFullName);
// openTeacher(teacherId!, teachersFullName);
},
child: Row(
children: [
Expand Down
325 changes: 164 additions & 161 deletions lib/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,186 +56,189 @@ class _LoginState extends State<Login> {
Widget build(BuildContext context) {
return Container(
alignment: Alignment.topCenter,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
constraints: const BoxConstraints(maxWidth: 500),
padding: const EdgeInsets.all(10),
child: Column(
children: [
(!isAuth)
? Column(
children: [
const Padding(
padding: EdgeInsets.only(bottom: 20),
child: Text(
textAlign: TextAlign.center,
"Login to you intranet.tam.ch Account",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20,
child: SafeArea(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
constraints: const BoxConstraints(maxWidth: 500),
padding: const EdgeInsets.only(
left: 10, top: 10, right: 10, bottom: 200),
child: Column(
children: [
(!isAuth)
? Column(
children: [
const Padding(
padding: EdgeInsets.only(bottom: 20),
child: Text(
textAlign: TextAlign.center,
"Login to you intranet.tam.ch Account",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
),
),
TextFormField(
initialValue: username,
onChanged: (value) {
username = value.toString();
},
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText:
'Intranet Benutzername (vorname.nachname)',
),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: TextField(
TextFormField(
initialValue: username,
onChanged: (value) {
password = value.toString();
username = value.toString();
},
obscureText: true,
enableSuggestions: false,
autocorrect: false,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText: 'Intranet Passwort',
focusColor: Colors.white),
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText:
'Intranet Benutzername (vorname.nachname)',
),
),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: TextField(
onChanged: (value) {
school = value.toString();
},
enableSuggestions: true,
autocorrect: false,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText: 'Schule kürzel (leer = kbw)',
focusColor: Colors.white),
Padding(
padding: const EdgeInsets.only(top: 20),
child: TextField(
onChanged: (value) {
password = value.toString();
},
obscureText: true,
enableSuggestions: false,
autocorrect: false,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText: 'Intranet Passwort',
focusColor: Colors.white),
),
),
),
errorMessage != null
? Text(
errorMessage.toString(),
style: const TextStyle(color: Colors.red),
)
: const SizedBox.shrink(),
Padding(
padding: const EdgeInsets.only(
top: 20, left: 20, right: 20),
child: Column(
children: const [
Text(
textAlign: TextAlign.center,
"This application is not associated with intranet.tam.ch!",
style: TextStyle(
color: Colors.blue,
),
),
Text(
textAlign: TextAlign.center,
"Your login details will be sent to kbw.senpai.one so that this website can log in to your account and load the timetable data. Your login data is not stored on the server. Your timetable data is temporarily cached on the server. Your login data is stored locally on this device until you log out.",
style: TextStyle(
color: Colors.white,
),
)
],
Padding(
padding: const EdgeInsets.only(top: 20),
child: TextField(
onChanged: (value) {
school = value.toString();
},
enableSuggestions: true,
autocorrect: false,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
)),
labelStyle: TextStyle(color: Colors.white),
labelText: 'Schule kürzel (leer = kbw)',
focusColor: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 40, 0, 20),
child: isLoading
? const Center(
child: CircularProgressIndicator(),
errorMessage != null
? Text(
errorMessage.toString(),
style: const TextStyle(color: Colors.red),
)
: ElevatedButton(
onPressed: () {
setState(() {
errorMessage = null;
isLoading = true;
});
fetchLoginApi().then((http.Response res) {
: const SizedBox.shrink(),
Padding(
padding: const EdgeInsets.only(
top: 20, left: 20, right: 20),
child: Column(
children: const [
Text(
textAlign: TextAlign.center,
"This application is not associated with intranet.tam.ch!",
style: TextStyle(
color: Colors.blue,
),
),
Text(
textAlign: TextAlign.center,
"Your login details will be sent to kbw.senpai.one so that this website can log in to your account and load the timetable data. Your login data is not stored on the server. Your timetable data is temporarily cached on the server. Your login data is stored locally on this device until you log out.",
style: TextStyle(
color: Colors.white,
),
)
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 40, 0, 20),
child: isLoading
? const Center(
child: CircularProgressIndicator(),
)
: ElevatedButton(
onPressed: () {
setState(() {
isLoading = false;
errorMessage = null;
isLoading = true;
});
if (res.statusCode == 200) {
fetchLoginApi().then((http.Response res) {
setState(() {
errorMessage = null;
isLoading = false;
});
SharedPreferences.getInstance()
.then((prefs) {
prefs.setString(
'username', username.toString());
prefs.setString(
'password', password.toString());
prefs.setString(
'school', school.toString());
if (res.statusCode == 200) {
setState(() {
isAuth = true;
errorMessage = null;
});
});
} else {
setState(() {
errorMessage = "Error: ${res.body}";
isAuth = false;
});
}
});
},
child: const Text(
"Anmelden",
style: TextStyle(color: Colors.white),
SharedPreferences.getInstance()
.then((prefs) {
prefs.setString('username',
username.toString());
prefs.setString('password',
password.toString());
prefs.setString(
'school', school.toString());
setState(() {
isAuth = true;
});
});
} else {
setState(() {
errorMessage = "Error: ${res.body}";
isAuth = false;
});
}
});
},
child: const Text(
"Anmelden",
style: TextStyle(color: Colors.white),
),
),
),
)
],
)
: Center(
child: ElevatedButton(
style: const ButtonStyle(
backgroundColor:
MaterialStatePropertyAll<Color>(Colors.red),
),
onPressed: () {
setState(() {
username = null;
password = null;
isAuth = false;
});
SharedPreferences.getInstance().then((prefs) {
prefs.setString('username', "");
prefs.setString('password', "");
});
},
child: Text(
"Abmelden",
style: TextStyle(color: Colors.white),
)
],
)
: Center(
child: ElevatedButton(
style: const ButtonStyle(
backgroundColor:
MaterialStatePropertyAll<Color>(Colors.red),
),
onPressed: () {
setState(() {
username = null;
password = null;
isAuth = false;
});
SharedPreferences.getInstance().then((prefs) {
prefs.setString('username', "");
prefs.setString('password', "");
});
},
child: Text(
"Abmelden",
style: TextStyle(color: Colors.white),
),
),
),
),
],
],
),
),
),
),
Expand Down
Loading

0 comments on commit cd52d07

Please sign in to comment.