general code cleanup

This commit is contained in:
Denys Konovalov 2021-11-19 20:12:42 +01:00
parent 223414559e
commit 649e226c66
9 changed files with 76 additions and 288 deletions

@ -33,11 +33,10 @@ class DevSettings extends StatelessWidget {
final snackBar = SnackBar( final snackBar = SnackBar(
content: content:
Text('Neuer API-Schlüssel gesetzt: $apiKey')); Text('Neuer API-Schlüssel gesetzt: $apiKey'));
// Find the ScaffoldMessenger in the widget tree
// and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(context).showSnackBar(snackBar);
})), }
)
),
const Divider(), const Divider(),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
@ -49,8 +48,10 @@ class DevSettings extends StatelessWidget {
); );
}, },
child: const Text("Benutzerdaten neu laden"), child: const Text("Benutzerdaten neu laden"),
)) )
)
], ],
)); )
);
} }
} }

@ -27,11 +27,9 @@ class InfoSettings extends StatelessWidget {
isScrollControlled: true, isScrollControlled: true,
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return SizedBox(
height: 400, height: 400,
//color: Colors.amber,
child: Column( child: Column(
//mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
AppBar( AppBar(
@ -41,10 +39,6 @@ class InfoSettings extends StatelessWidget {
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Text(""), child: Text(""),
), ),
/*ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () => Navigator.pop(context),
)*/
], ],
), ),
); );

@ -111,68 +111,6 @@ class _PlanSettingsState extends State<PlanSettings> {
return (const Center(child: CircularProgressIndicator())); return (const Center(child: CircularProgressIndicator()));
} }
}), }),
/*FutureBuilder(
future: buildPlanColors("Mat"),
builder: (context, snapshot) {
if (snapshot.hasData) {
Color color = snapshot.data as Color;
return ListTile(
leading: ColorButton(
key: const Key('c1'),
color: color,
//boxShape: BoxShape.circle, // default : circle
config: const ColorPickerConfig(enableEyePicker: false),
onSwatchesChanged: (Set<Color> value) {
swatches = value;
},
size: 32,
swatches: swatches,
onColorChanged: (Color value) async {
setState(() {
color = value;
});
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setInt("colorMat", value.value);
}
),
title: const Text("Mathematik"),
);
} else {
return (const Center(child: CircularProgressIndicator()));
}
}
),
FutureBuilder(
future: buildPlanColors("Bio"),
builder: (context, snapshot) {
if (snapshot.hasData) {
Color color = snapshot.data as Color;
return ListTile(
leading: ColorButton(
key: const Key('c1'),
color: color,
//boxShape: BoxShape.circle, // default : circle
config: const ColorPickerConfig(enableEyePicker: false),
onSwatchesChanged: (Set<Color> value) {
swatches = value;
},
size: 32,
swatches: swatches,
onColorChanged: (Color value) async {
setState(() {
color = value;
});
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setInt("colorBio", value.value);
}
),
title: const Text("Biologie"),
);
} else {
return (const Center(child: CircularProgressIndicator()));
}
}
),*/
], ],
)); ));
} }

@ -36,7 +36,10 @@ class UserSettings extends StatelessWidget {
image: DecorationImage( image: DecorationImage(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
image: image:
AssetImage("assets/images/meincantor_r.png")))), AssetImage("assets/images/meincantor_r.png")
)
)
),
), ),
FutureBuilder( FutureBuilder(
future: getSettingsString("name"), future: getSettingsString("name"),
@ -59,6 +62,7 @@ class UserSettings extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(5, 20, 5, 5), padding: const EdgeInsets.fromLTRB(5, 20, 5, 5),
child: buildClassesChooser()), child: buildClassesChooser()),
], ],
)); )
);
} }
} }

@ -174,6 +174,11 @@ class _DashboardBottomNavView extends StatelessWidget {
_timeOfDayToDouble(TimeOfDay.now()) <= _timeOfDayToDouble(TimeOfDay.now()) <=
_timeOfDayToDouble(const TimeOfDay(hour: 15, minute: 10))) { _timeOfDayToDouble(const TimeOfDay(hour: 15, minute: 10))) {
lessonCount = 9; lessonCount = 9;
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
_timeOfDayToDouble(const TimeOfDay(hour: 15, minute: 10)) &&
_timeOfDayToDouble(TimeOfDay.now()) <=
_timeOfDayToDouble(const TimeOfDay(hour: 16, minute: 00))) {
lessonCount = 10;
} else { } else {
lessonCount = -1; lessonCount = -1;
} }

@ -25,7 +25,7 @@ class Login extends StatelessWidget {
builder: (context, constraints) { builder: (context, constraints) {
double widgetWidth = constraints.maxWidth; double widgetWidth = constraints.maxWidth;
//double widgetHeight = constraints.maxHeight; //double widgetHeight = constraints.maxHeight;
var factor; int factor;
if (widgetWidth <= 600) { if (widgetWidth <= 600) {
factor = 1; factor = 1;
@ -33,6 +33,8 @@ class Login extends StatelessWidget {
factor = 2; factor = 2;
} else if (widgetWidth <= 2000) { } else if (widgetWidth <= 2000) {
factor = 3; factor = 3;
} else {
factor = 4;
} }
return Scaffold( return Scaffold(
@ -93,15 +95,6 @@ class Login extends StatelessWidget {
obscureText: true, obscureText: true,
controller: otpController, controller: otpController,
), ),
/*const Divider(),
TextField(
decoration: const InputDecoration(
icon: Icon(CupertinoIcons.device_laptop),
border: OutlineInputBorder(),
labelText: 'Gerätebezeichnung',
),
controller: devIdController,
),*/
const Divider(), const Divider(),
OutlinedButton( OutlinedButton(
onPressed: () async { onPressed: () async {
@ -115,7 +108,6 @@ class Login extends StatelessWidget {
if (loginResponse.statusCode == 200) { if (loginResponse.statusCode == 200) {
String apiKey = jsonDecode(utf8.decode( String apiKey = jsonDecode(utf8.decode(
loginResponse.bodyBytes))['token']; loginResponse.bodyBytes))['token'];
print('Set new API key to $apiKey');
await prefs.setString('api_key', apiKey); await prefs.setString('api_key', apiKey);
dynamic userinfo = jsonDecode( dynamic userinfo = jsonDecode(
await getUserInfo( await getUserInfo(
@ -136,9 +128,6 @@ class Login extends StatelessWidget {
String text = loginResponse.body; String text = loginResponse.body;
final snackBar = SnackBar( final snackBar = SnackBar(
content: Text('Fehler: $text')); content: Text('Fehler: $text'));
// Find the ScaffoldMessenger in the widget tree
// and use it to show a SnackBar.
ScaffoldMessenger.of(context) ScaffoldMessenger.of(context)
.showSnackBar(snackBar); .showSnackBar(snackBar);
} }
@ -159,7 +148,11 @@ class Login extends StatelessWidget {
child: const Text("Anmelden")) child: const Text("Anmelden"))
], ],
), ),
))))); )
)
)
)
);
}, },
); );
} }

@ -11,12 +11,8 @@ import 'package:MeinCantor/login.dart';
import 'package:MeinCantor/main.dart'; import 'package:MeinCantor/main.dart';
Future<http.Response> getArticles() async { Future<http.Response> getArticles() async {
print("hjkl0");
var uri = Uri.https(szUrl["url"]!, "/articles"); var uri = Uri.https(szUrl["url"]!, "/articles");
print(uri.toString());
final response = await http.get(uri); final response = await http.get(uri);
print("hji");
print(response);
return (response); return (response);
} }
@ -25,7 +21,6 @@ Future<http.Response> getToken(
var uri = Uri.https("mein.cantorgymnasium.de", "/login"); var uri = Uri.https("mein.cantorgymnasium.de", "/login");
String body = String body =
'{"user":"$user", "password": "$password", "otp": "$otp", "devid": "$devId"}'; '{"user":"$user", "password": "$password", "otp": "$otp", "devid": "$devId"}';
print(uri);
final response = await http.post(uri, body: body); final response = await http.post(uri, body: body);
return (response); return (response);
} }
@ -35,7 +30,6 @@ Future<String> getUserInfo(
var uri = Uri.https("mein.cantorgymnasium.de", "/api/userinfo"); var uri = Uri.https("mein.cantorgymnasium.de", "/api/userinfo");
String body = String body =
'{"user":"$user", "password": "$password", "otp": "$otp", "devid": "$devId"}'; '{"user":"$user", "password": "$password", "otp": "$otp", "devid": "$devId"}';
print(uri);
final response = await http.post(uri, body: body); final response = await http.post(uri, body: body);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -45,29 +39,26 @@ Future<String> getUserInfo(
} }
} }
Future<http.Response> fetchClassTimetable() async { Future<http.Response> fetchClassTimetable(String ext) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String classNum; String classNum;
print(prefs.getString('class_num'));
if (prefs.getString('class_num') != null) { if (prefs.getString('class_num') != null) {
classNum = prefs.getString('class_num')!.replaceAll("/", "_"); classNum = prefs.getString('class_num')!.replaceAll("/", "_");
} else { } else {
classNum = '05_1'; classNum = '05_1';
} }
var apiKey = prefs.getString('api_key'); var apiKey = prefs.getString('api_key');
var uri = Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum"); var uri = Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum$ext");
var headers = {"x-api-key": "$apiKey"}; var headers = {"x-api-key": "$apiKey"};
print(uri);
final response = http.get(uri, headers: headers).onError((error, stackTrace) { final response = http.get(uri, headers: headers).onError((error, stackTrace) {
return (http.Response("", 404)); return (http.Response("", 404));
}); });
return response; return response;
} }
Future<http.Response> fetchTodayClassTimetable() async { /*Future<http.Response> fetchTodayClassTimetable() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String classNum; String classNum;
print(prefs.getString('class_num'));
if (prefs.getString('class_num') != null) { if (prefs.getString('class_num') != null) {
classNum = prefs.getString('class_num')!.replaceAll("/", "_"); classNum = prefs.getString('class_num')!.replaceAll("/", "_");
} else { } else {
@ -77,7 +68,6 @@ Future<http.Response> fetchTodayClassTimetable() async {
var uri = var uri =
Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum/today"); Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum/today");
var headers = {"x-api-key": "$apiKey"}; var headers = {"x-api-key": "$apiKey"};
print(uri);
final response = http.get(uri, headers: headers).onError((error, stackTrace) { final response = http.get(uri, headers: headers).onError((error, stackTrace) {
return (http.Response("", 404)); return (http.Response("", 404));
}); });
@ -87,7 +77,6 @@ Future<http.Response> fetchTodayClassTimetable() async {
Future<http.Response> fetchTomorrowClassTimetable() async { Future<http.Response> fetchTomorrowClassTimetable() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String classNum; String classNum;
print(prefs.getString('class_num'));
if (prefs.getString('class_num') != null) { if (prefs.getString('class_num') != null) {
classNum = prefs.getString('class_num')!.replaceAll("/", "_"); classNum = prefs.getString('class_num')!.replaceAll("/", "_");
} else { } else {
@ -97,12 +86,11 @@ Future<http.Response> fetchTomorrowClassTimetable() async {
var uri = var uri =
Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum/tomorrow"); Uri.https("mein.cantorgymnasium.de", "/api/timetable/$classNum/tomorrow");
var headers = {"x-api-key": "$apiKey"}; var headers = {"x-api-key": "$apiKey"};
print(uri);
final response = http.get(uri, headers: headers).onError((error, stackTrace) { final response = http.get(uri, headers: headers).onError((error, stackTrace) {
return (http.Response("", 404)); return (http.Response("", 404));
}); });
return response; return response;
} }*/
fetchLessonList() async { fetchLessonList() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
@ -127,101 +115,20 @@ fetchLessonList() async {
} }
Widget buildClassTimetable() { Widget buildClassTimetable() {
return FutureBuilder<http.Response>( return buildTimetable(fetchClassTimetable(""), "aktueller Vertretungsplan");
future: fetchClassTimetable(),
builder: (context, snapshot) {
if (snapshot.hasData) {
int statusCode = snapshot.data!.statusCode;
if (statusCode == 200) {
Widget timetableView = ClassTimetableBuilder.buildView(
jsonDecode(utf8.decode(snapshot.data!.bodyBytes)), context)
.view
.child;
return timetableView;
} else if (statusCode == 400) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => Login()));
} else if (statusCode == 500) {
return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: Text("Es konnte kein Vertretungsplan gefunden werden.")),
);
} else if (statusCode == 404) {
return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: Text(
"Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internetverbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support.")),
);
}
return Center(child: Text('Error $statusCode'));
} else if (snapshot.hasError) {
return Text('$snapshot.error');
} else {
return const Center(child: CircularProgressIndicator());
}
},
);
} }
Widget buildTodayClassTimetable() { Widget buildTodayClassTimetable() {
return FutureBuilder<http.Response>( return buildTimetable(fetchClassTimetable("/today"), "Vertretungsplan für heute");
future: fetchTodayClassTimetable(),
builder: (context, snapshot) {
if (snapshot.hasData) {
int statusCode = snapshot.data!.statusCode;
if (statusCode == 200) {
Widget timetableView = ClassTimetableBuilder.buildView(
jsonDecode(utf8.decode(snapshot.data!.bodyBytes)), context)
.view
.child;
return timetableView;
} else if (statusCode == 400) {
Navigator.push(
context, MaterialPageRoute(builder: (context) => Login()));
} else if (statusCode == 500) {
var chars = Runes(
'Es konnte kein Vertretungsplan für heute gefunden werden. \u{1F937}');
List<Widget> cardChildren = [];
cardChildren.add(ListTile(
title: Text(String.fromCharCodes(chars),
style: const TextStyle(color: Palette.primary)),
));
Card card = Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.white,
child: Column(
children: cardChildren,
));
return Padding(
padding: EdgeInsets.fromLTRB(20, 20, 20, 20),
child: ListView(
children: [card],
));
} else if (statusCode == 404) {
return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: Text(
"Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internetverbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support.")),
);
}
return Center(child: Text('Error $statusCode'));
} else if (snapshot.hasError) {
return Text('$snapshot.error');
} else {
return const Center(child: CircularProgressIndicator());
}
},
);
} }
Widget buildTomorrowClassTimetable() { Widget buildTomorrowClassTimetable() {
return buildTimetable(fetchClassTimetable("/tomorrow"), "Vertretungsplan für morgen");
}
Widget buildTimetable(Future<http.Response> future, String info) {
return FutureBuilder<http.Response>( return FutureBuilder<http.Response>(
future: fetchTomorrowClassTimetable(), future: future,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
int statusCode = snapshot.data!.statusCode; int statusCode = snapshot.data!.statusCode;
@ -236,7 +143,7 @@ Widget buildTomorrowClassTimetable() {
context, MaterialPageRoute(builder: (context) => Login())); context, MaterialPageRoute(builder: (context) => Login()));
} else if (statusCode == 500) { } else if (statusCode == 500) {
var chars = Runes( var chars = Runes(
'Es konnte kein Vertretungsplan für morgen gefunden werden. \u{1F937}'); 'Es konnte kein $info gefunden werden. \u{1F937}');
List<Widget> cardChildren = []; List<Widget> cardChildren = [];
cardChildren.add(ListTile( cardChildren.add(ListTile(
title: Text(String.fromCharCodes(chars), title: Text(String.fromCharCodes(chars),
@ -251,54 +158,18 @@ Widget buildTomorrowClassTimetable() {
children: cardChildren, children: cardChildren,
)); ));
return Padding( return Padding(
padding: EdgeInsets.fromLTRB(20, 20, 20, 20), padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: ListView( child: ListView(
children: [card], children: [card],
)); ));
/*return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(child: Text("Es konnte kein Vertretungsplan für heute gefunden werden.")),
);*/
} else if (statusCode == 404) { } else if (statusCode == 404) {
return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: Text(
"Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internetverbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support.")),
);
}
return Center(child: Text('Error $statusCode'));
} else if (snapshot.hasError) {
return Text('$snapshot.error');
} else {
return const Center(child: CircularProgressIndicator());
}
},
);
}
Widget buildClassTimetableLesson(int count) {
return FutureBuilder<http.Response>(
future: fetchClassTimetable(),
builder: (context, snapshot) {
if (snapshot.hasData) {
int statusCode = snapshot.data!.statusCode;
if (statusCode == 200) {
List<Widget> lessons = LessonsListBuilder.buildList(
jsonDecode(utf8.decode(snapshot.data!.bodyBytes)),
count: count)
.lessons;
return Column(children: lessons);
} else if (statusCode == 400) {
Navigator.push(
context, MaterialPageRoute(builder: (context) => Login()));
} else if (statusCode == 500) {
var chars = Runes( var chars = Runes(
'Es konnte kein Vertretungsplan für gefunden werden. \u{1F937}'); 'Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internet-Verbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support. \u{1F4e1}');
List<Widget> cardChildren = []; List<Widget> cardChildren = [];
cardChildren.add(ListTile( cardChildren.add(ListTile(
title: Text(String.fromCharCodes(chars), title: Text(String.fromCharCodes(chars),
style: const TextStyle(color: Palette.primary)))); style: const TextStyle(color: Palette.primary)),
));
Card card = Card( Card card = Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
@ -307,17 +178,11 @@ Widget buildClassTimetableLesson(int count) {
child: Column( child: Column(
children: cardChildren, children: cardChildren,
)); ));
return card; return Padding(
/*return const Padding( padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
padding: EdgeInsets.fromLTRB(10, 10, 10, 10), child: ListView(
child: Center(child: Text("Es konnte kein Vertretungsplan gefunden werden.")), children: [card],
);*/ )
} else if (statusCode == 404) {
return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: Text(
"Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internetverbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support")),
); );
} }
return Center(child: Text('Error $statusCode')); return Center(child: Text('Error $statusCode'));
@ -332,7 +197,7 @@ Widget buildClassTimetableLesson(int count) {
Widget buildTodayClassTimetableLesson(int count) { Widget buildTodayClassTimetableLesson(int count) {
return FutureBuilder<http.Response>( return FutureBuilder<http.Response>(
future: fetchTodayClassTimetable(), future: fetchClassTimetable("/today"),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
int statusCode = snapshot.data!.statusCode; int statusCode = snapshot.data!.statusCode;
@ -383,16 +248,27 @@ Widget buildTodayClassTimetableLesson(int count) {
children: cardChildren, children: cardChildren,
)); ));
return card; return card;
/*return const Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(child: Text("Es konnte kein Vertretungsplan für heute gefunden werden.")),
);*/
} else if (statusCode == 404) { } else if (statusCode == 404) {
return const Padding( var chars = Runes(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10), 'Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internet-Verbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support. \u{1F4e1}');
child: Center( List<Widget> cardChildren = [];
child: Text( cardChildren.add(ListTile(
"Keine Verbindung mit dem MeinCantor-Server möglich. Bitte prüfe deine Internetverbindung und deine DNS-Einstellungen oder wende dich an den MeinCantor-Support")), title: Text(String.fromCharCodes(chars),
style: const TextStyle(color: Palette.primary)),
));
Card card = Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.white,
child: Column(
children: cardChildren,
));
return Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: ListView(
children: [card],
)
); );
} }
return Center(child: Text('Error $statusCode')); return Center(child: Text('Error $statusCode'));
@ -410,7 +286,6 @@ Future<http.Response> fetchClassesList() async {
var apiKey = prefs.getString('api_key'); var apiKey = prefs.getString('api_key');
var uri = Uri.https("mein.cantorgymnasium.de", "/api/classes"); var uri = Uri.https("mein.cantorgymnasium.de", "/api/classes");
var headers = {"x-api-key": "$apiKey"}; var headers = {"x-api-key": "$apiKey"};
print(uri);
final response = http.get(uri, headers: headers).onError((error, stackTrace) { final response = http.get(uri, headers: headers).onError((error, stackTrace) {
return (http.Response("", 404)); return (http.Response("", 404));
}); });
@ -498,7 +373,6 @@ class _ClassesChooserState extends State<ClassesChooser> {
dropdownValue = newValue!; dropdownValue = newValue!;
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String classNum = newValue; String classNum = newValue;
print('Set new class to $classNum');
await prefs.setString('class_num', classNum); await prefs.setString('class_num', classNum);
}); });
}, },

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:MeinCantor/networking.dart'; import 'package:MeinCantor/networking.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
@ -89,40 +90,17 @@ class Article {
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
children: [ children: [
ListTile( ListTile(
leading: Icon(MdiIcons.accountOutline), leading: const Icon(MdiIcons.accountOutline),
title: Text(author), title: Text(author),
), ),
ListTile( ListTile(
leading: Icon(MdiIcons.calendarOutline), leading: const Icon(MdiIcons.calendarOutline),
title: Text("${DateTime.parse(publishDate).day.toString()}.${DateTime.parse(publishDate).month.toString()}.${DateTime.parse(publishDate).year.toString()}"), title: Text("${DateTime.parse(publishDate).day.toString()}.${DateTime.parse(publishDate).month.toString()}.${DateTime.parse(publishDate).year.toString()}"),
), ),
Text(content) MarkdownBody(data: content)
], ],
) )
) )
); );
} }
//@override
/*Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Schülersprecherwahl 2021: Kandidatenduos im Interview"),
centerTitle: true,
),
body: ListView(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
children: const [
Text("""
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer
""")
],
));
}*/
} }

@ -41,6 +41,7 @@ dependencies:
flutter_colorpicker: ^0.6.0 flutter_colorpicker: ^0.6.0
material_design_icons_flutter: ^5.0.5955-rc.1 material_design_icons_flutter: ^5.0.5955-rc.1
cyclop: ^0.5.2 cyclop: ^0.5.2
flutter_markdown: ^0.6.8
flutter_icons: flutter_icons:
# image_path: "assets/images/icon-128x128.png" # image_path: "assets/images/icon-128x128.png"