diff --git a/lib/Views/Informations.dart b/lib/Views/Informations.dart new file mode 100644 index 0000000..41801d6 --- /dev/null +++ b/lib/Views/Informations.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +import '../api/api.dart'; +import '../components/helpers.dart'; +import '../components/informations.dart'; + +class Information extends StatelessWidget { + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Informationen"), + ), + body: ResourceListBuilder( + API.of(context).requests.getInformation, + (data, controller) => ListView( + controller: controller, + children: [ + Align( + alignment: AlignmentDirectional.topCenter, + child: Wrap( + children: data.map((information) => InformationListEntry(information)).toList(), + ), + )], + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/Views/Views.dart b/lib/Views/Views.dart index 012832d..f9f0dd6 100644 --- a/lib/Views/Views.dart +++ b/lib/Views/Views.dart @@ -1,12 +1,13 @@ import 'package:flutter/cupertino.dart'; -import './Calendar.dart' as Calendar; // ignore: library_prefixes -import './Home.dart' as Home; // ignore: library_prefixes -import './Login.dart' as Login; // ignore: library_prefixes -import './News.dart' as News; // ignore: library_prefixes -import './RPlan.dart' as RPlan; // ignore: library_prefixes -import './User.dart' as User; // ignore: library_prefixes -import './WebMail.dart' as WebMail; // ignore: library_prefixes +import './Calendar.dart' as Calendar; // ignore: library_prefixes +import './Home.dart' as Home; // ignore: library_prefixes +import './Informations.dart' as Information; // ignore: library_prefixes +import './Login.dart' as Login; // ignore: library_prefixes +import './News.dart' as News; // ignore: library_prefixes +import './RPlan.dart' as RPlan; // ignore: library_prefixes +import './User.dart' as User; // ignore: library_prefixes +import './WebMail.dart' as WebMail; // ignore: library_prefixes import '../main.dart'; @@ -21,6 +22,7 @@ List AppViews(AppType type) { new Home.Home(), new Calendar.Calendar(), new News.News(), + new Information.Information(), new Login.Login(), ]; case AppType.NORMAL: @@ -29,6 +31,7 @@ List AppViews(AppType type) { new Home.Home(), new Calendar.Calendar(), new News.News(), + new Information.Information(), new User.User(), new RPlan.RPlanViewWidget(), if (type == AppType.NORMAL_WITH_WEBMAIL) WebMail.WebMail(), @@ -45,6 +48,7 @@ List AppViews(AppType type) { case AppType.MOBILE_SITE: return [ new News.News(), + new Information.Information(), new Calendar.Calendar(), new Login.Login(), ]; @@ -56,13 +60,13 @@ List AppViews(AppType type) { int getPageCount(AppType type) { switch (type) { case AppType.LOGGED_OUT: - return 4; + return 5; break; case AppType.NORMAL: - return 5; + return 6; break; case AppType.NORMAL_WITH_WEBMAIL: - return 6; + return 7; break; case AppType.VPLAN_LOGGED_OUT: return 1; @@ -71,7 +75,7 @@ int getPageCount(AppType type) { return 2; break; case AppType.MOBILE_SITE: - return 3; + return 4; break; } return 0; diff --git a/lib/api/api.dart b/lib/api/api.dart index 97f32fc..f0d0dc3 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -354,6 +354,16 @@ class _APIRequests { return new helpers.ListResource.load("articles", params); } + helpers.ListResource getInformation() { + // Not calling actionExecution here, because login not needed and needs async + Map params = {}; + params['view'] = "preview-with-image"; + params['tags'] = "eq-7GGb4jjj11wXYKdD00XPJt"; + params['orderby'] = "asc-title"; + + return new helpers.ListResource.load("articles", params); + } + Future getArticle(String id) async { await _actionExecution(APIAction.GET_ARTICLE); diff --git a/lib/components/informations.dart b/lib/components/informations.dart new file mode 100644 index 0000000..63d6bfa --- /dev/null +++ b/lib/components/informations.dart @@ -0,0 +1,34 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; + +import '../Views/News.dart'; +import '../api/api_models.dart'; +import '../api/api_raw.dart' as raw_api; + +class InformationListEntry extends StatelessWidget { + final Article information; + + InformationListEntry(this.information); + + @override + Widget build(BuildContext context) { + return ListTile( + title: Text(information.title), + leading: + information.imageID != null ? + ClipRRect( + borderRadius: BorderRadius.circular(50.0), + child: CachedNetworkImage( + imageUrl: "${raw_api.API}files/${information.imageID}", + width: 50, + ), + ) : + Padding( + child: Icon(Icons.info, size: 30), + padding: EdgeInsets.all(10), + ), + onTap: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => ArticleDetail(information))), + ); + } +} \ No newline at end of file diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 74e3762..8fff69b 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -110,6 +110,10 @@ class BottomNavigationBarMenu extends StatelessWidget { text: "News", icon: Icon(Icons.public, size: 35), ), + Tab( + text: "Infos", + icon: Icon(Icons.info_outline, size: 35), + ), Tab( text: "Login", icon: Icon(Icons.person, size: 35), @@ -131,6 +135,10 @@ class BottomNavigationBarMenu extends StatelessWidget { text: "News", icon: Icon(Icons.public, size: 35), ), + Tab( + text: "Infos", + icon: Icon(Icons.info_outline, size: 35), + ), Tab( text: "SPlan", icon: Icon(Icons.widgets, size: 35), @@ -171,6 +179,10 @@ class BottomNavigationBarMenu extends StatelessWidget { text: "News", icon: Icon(Icons.public, size: 35), ), + Tab( + text: "Infos", + icon: Icon(Icons.info_outline, size: 35), + ), Tab( text: "Termine", icon: Icon(Icons.event, size: 35), @@ -217,6 +229,10 @@ List getNavigationRail(AppType type) { label: Text("News"), icon: Icon(Icons.public, size: 35), ), + NavigationRailDestination( + label: Text("Infos"), + icon: Icon(Icons.info_outline, size: 35), + ), NavigationRailDestination( label: Text("Login"), icon: Icon(Icons.person, size: 35), @@ -237,6 +253,10 @@ List getNavigationRail(AppType type) { label: Text("News"), icon: Icon(Icons.public, size: 35), ), + NavigationRailDestination( + label: Text("Infos"), + icon: Icon(Icons.info_outline, size: 35), + ), NavigationRailDestination( label: Text("SPlan"), icon: Icon(Icons.widgets, size: 35), @@ -278,6 +298,10 @@ List getNavigationRail(AppType type) { label: Text("News"), icon: Icon(Icons.public, size: 35), ), + NavigationRailDestination( + label: Text("Infos"), + icon: Icon(Icons.info_outline, size: 35), + ), NavigationRailDestination( label: Text("Termine"), icon: Icon(Icons.event, size: 35),