Skip to content

Commit

Permalink
✨ Add Info view
Browse files Browse the repository at this point in the history
  • Loading branch information
strifel committed Mar 29, 2022
1 parent e84a0f9 commit 7ae46d3
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 11 deletions.
30 changes: 30 additions & 0 deletions lib/Views/Informations.dart
Original file line number Diff line number Diff line change
@@ -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<Widget>((information) => InformationListEntry(information)).toList(),
),
)],
)
)
);
}
}
26 changes: 15 additions & 11 deletions lib/Views/Views.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -21,6 +22,7 @@ List<Widget> AppViews(AppType type) {
new Home.Home(),
new Calendar.Calendar(),
new News.News(),
new Information.Information(),
new Login.Login(),
];
case AppType.NORMAL:
Expand All @@ -29,6 +31,7 @@ List<Widget> 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(),
Expand All @@ -45,6 +48,7 @@ List<Widget> AppViews(AppType type) {
case AppType.MOBILE_SITE:
return <Widget>[
new News.News(),
new Information.Information(),
new Calendar.Calendar(),
new Login.Login(),
];
Expand All @@ -56,13 +60,13 @@ List<Widget> 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;
Expand All @@ -71,7 +75,7 @@ int getPageCount(AppType type) {
return 2;
break;
case AppType.MOBILE_SITE:
return 3;
return 4;
break;
}
return 0;
Expand Down
10 changes: 10 additions & 0 deletions lib/api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ class _APIRequests {
return new helpers.ListResource<models.Article>.load("articles", params);
}

helpers.ListResource<models.Article> getInformation() {
// Not calling actionExecution here, because login not needed and needs async
Map<String, String> params = {};
params['view'] = "preview-with-image";
params['tags'] = "eq-7GGb4jjj11wXYKdD00XPJt";
params['orderby'] = "asc-title";

return new helpers.ListResource<models.Article>.load("articles", params);
}

Future<models.Article> getArticle(String id) async {
await _actionExecution(APIAction.GET_ARTICLE);

Expand Down
34 changes: 34 additions & 0 deletions lib/components/informations.dart
Original file line number Diff line number Diff line change
@@ -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))),
);
}
}
24 changes: 24 additions & 0 deletions lib/components/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -217,6 +229,10 @@ List<NavigationRailDestination> 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),
Expand All @@ -237,6 +253,10 @@ List<NavigationRailDestination> 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),
Expand Down Expand Up @@ -278,6 +298,10 @@ List<NavigationRailDestination> 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),
Expand Down

0 comments on commit 7ae46d3

Please sign in to comment.