2022-01-16 15:28:42 +01:00
|
|
|
// GCG.MeinCantor - Die Schulplattform für Cantorianer.
|
|
|
|
// Copyright (C) 2021-2022 Georg-Cantor-Gymnasium Halle (Saale)
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published
|
|
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2021-12-19 22:20:56 +01:00
|
|
|
import 'package:background_fetch/background_fetch.dart';
|
2021-11-06 11:01:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
2021-12-19 22:20:56 +01:00
|
|
|
import 'package:meincantor/background_fetch.dart';
|
2021-11-06 11:01:44 +01:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
2021-12-19 22:20:56 +01:00
|
|
|
import 'package:meincantor/login.dart';
|
2021-11-06 11:01:44 +01:00
|
|
|
|
2021-12-19 22:20:56 +01:00
|
|
|
class DevSettings extends StatefulWidget {
|
2021-11-06 11:01:44 +01:00
|
|
|
const DevSettings({Key? key}) : super(key: key);
|
|
|
|
|
2021-12-19 22:20:56 +01:00
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _DevSettingsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DevSettingsState extends State<DevSettings> {
|
|
|
|
int _status = 0;
|
|
|
|
|
|
|
|
void _onClickStatus() async {
|
|
|
|
int status = await BackgroundFetch.status;
|
|
|
|
print('[BackgroundFetch] status: $status');
|
|
|
|
setState(() {
|
|
|
|
_status = status;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-06 11:01:44 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text("Entwickler-Einstellungen"),
|
|
|
|
centerTitle: true,
|
|
|
|
),
|
2021-12-19 22:20:56 +01:00
|
|
|
body: LayoutBuilder(builder: (context, constraints) {
|
|
|
|
double widgetWidth = constraints.maxWidth;
|
|
|
|
|
|
|
|
int factor;
|
|
|
|
|
|
|
|
if (widgetWidth <= 600) {
|
|
|
|
factor = 1;
|
|
|
|
} else if (widgetWidth <= 1400) {
|
|
|
|
factor = 2;
|
|
|
|
} else if (widgetWidth <= 2000) {
|
|
|
|
factor = 3;
|
|
|
|
} else {
|
|
|
|
factor = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
heightFactor: 1,
|
|
|
|
child: Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
maxWidth: MediaQuery.of(context).size.width / factor,
|
|
|
|
),
|
|
|
|
child: ListView(
|
|
|
|
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: TextField(
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
icon: Icon(MdiIcons.keyOutline),
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
labelText: 'MeinCantor API-Schlüssel',
|
|
|
|
),
|
|
|
|
onSubmitted: (String value) async {
|
|
|
|
SharedPreferences prefs =
|
|
|
|
await SharedPreferences.getInstance();
|
|
|
|
String apiKey = value;
|
|
|
|
await prefs.setString('api_key', apiKey);
|
|
|
|
final snackBar = SnackBar(
|
|
|
|
content: Text(
|
|
|
|
'Neuer API-Schlüssel gesetzt: $apiKey'));
|
|
|
|
ScaffoldMessenger.of(context)
|
|
|
|
.showSnackBar(snackBar);
|
|
|
|
})),
|
|
|
|
const Divider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => Login()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: const Text("Benutzerdaten neu laden"),
|
|
|
|
)),
|
|
|
|
const Divider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: () {
|
|
|
|
_onClickStatus();
|
|
|
|
},
|
|
|
|
child: const Text(
|
|
|
|
"Status der Hintergrundoperation anzeigen"),
|
|
|
|
)),
|
|
|
|
const Divider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
|
|
|
|
child: Text(_status.toString())),
|
|
|
|
const Divider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: () async {
|
|
|
|
await backgroundFetchTimetable();
|
|
|
|
},
|
|
|
|
child: const Text(
|
|
|
|
"Stundenplan im Hintergrund neu laden"),
|
|
|
|
)),
|
|
|
|
const Divider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: () async {
|
|
|
|
await backgroundFetchArticles();
|
|
|
|
},
|
|
|
|
child: const Text(
|
|
|
|
"Schülerzeitung im Hintergrund neu laden"),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}));
|
2021-11-06 11:01:44 +01:00
|
|
|
}
|
2021-11-16 19:41:35 +01:00
|
|
|
}
|