Commit e2cb40f2 authored by wonko's avatar wonko

toggle like button

parent 4f05d6d8
......@@ -5,6 +5,7 @@ import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Assets {
Future<Map<String, dynamic>> loadJSON(file) async {
......@@ -136,8 +137,9 @@ class Room {
}
class Lecture {
String fs, name, teaser, time, room, id;
bool aufz;
final String fs, name, teaser, time, room, id;
final bool aufz;
bool like = false;
Lecture(final this.fs, final this.name, final this.teaser, final this.aufz,
final this.time, final this.room, final this.id);
......@@ -149,5 +151,6 @@ class Lecture {
} else {
return null;
}
}
}
......@@ -54,7 +54,6 @@ class _ScheduleWidgetState extends State<ScheduleWidget>
});
}
List<Widget> roomViews() {
List<Widget> rv = [];
for (Room room in lectureData.data.rooms) {
......@@ -106,14 +105,19 @@ class RoomSchedule extends StatelessWidget {
itemCount: room.timeSlots.length,
itemBuilder: (context, index) => Column(children: <Widget>[
Divider(),
Expanded(child: getLectureCard(index, context))
Expanded(child: LectureCard(room.timeSlots[index].lecture))
])));
}
}
class _LectureCardState extends State<LectureCard> {
final Lecture l;
_LectureCardState(this.l);
Widget getLectureCard(int index, BuildContext context) {
if (room.timeSlots[index].lecture != null) {
Lecture l = room.timeSlots[index].lecture;
@override
Widget build(BuildContext context) {
if (l != null) {
IconData ico = Fachschaften().getIcon(l.fs);
return Container(
padding:
......@@ -138,9 +142,15 @@ class RoomSchedule extends StatelessWidget {
child: ButtonBar(
children: <Widget>[
IconButton(
icon: Icon(Icons.favorite_border),
tooltip: 'Increase volume by 10',
onPressed: () {}),
icon: l.like
? Icon(Icons.favorite)
: Icon(Icons.favorite_border),
tooltip: 'blah',
onPressed: () {
setState(() {
l.like = !l.like;
});
}),
],
),
),
......@@ -152,3 +162,12 @@ class RoomSchedule extends StatelessWidget {
}
}
}
class LectureCard extends StatefulWidget {
final Lecture lecture;
LectureCard(this.lecture);
@override
_LectureCardState createState() => _LectureCardState(lecture);
}
......@@ -167,6 +167,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.2"
sky_engine:
dependency: transitive
description: flutter
......
......@@ -26,6 +26,7 @@ dependencies:
cupertino_icons: ^0.1.2
path_provider: ^0.5.0
flutter_cache_manager: ^0.3.2
shared_preferences: ^0.5.2
dev_dependencies:
flutter_test:
sdk: flutter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment