Commit 05c7962e authored by Luca Braun's avatar Luca Braun

Merge remote-tracking branch 'origin/feature/dashboard' into feature/dashboard

parents 3a20813c d067c9b1
...@@ -12,4 +12,10 @@ class Post { ...@@ -12,4 +12,10 @@ class Post {
if (title != null && title.isNotEmpty) return title; if (title != null && title.isNotEmpty) return title;
return content; return content;
} }
String get effectiveContent {
if (content != null && content.isNotEmpty) return content;
return title;
}
} }
import 'package:dashboard/graphing/usergraph.dart'; import 'package:dashboard/graphing/usergraph.dart';
import 'package:dashboard/ui/graphs/community/index.dart'; import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../data/post.dart'; import '../data/post.dart';
import 'trustcolorcalculator.dart'; import 'trustcolorcalculator.dart';
class PostNode extends StatelessWidget { class PostNode extends StatelessWidget {
final Post post; final Post post;
PostNode(this.post); final Color trustColor;
Color trustColor = Colors.transparent; PostNode(this.post)
: trustColor = TrustColorCalculator.calculateTrustColor(post.trust);
Widget build(BuildContext context) { Widget build(BuildContext context) {
trustColor = TrustColorCalculator.calculateTrustColor(post.trust);
return GestureDetector( return GestureDetector(
onTap: () => redirectToPost(context), onTap: () => redirectToPost(context),
child: Row( child: Row(
...@@ -37,133 +36,91 @@ class PostNode extends StatelessWidget { ...@@ -37,133 +36,91 @@ class PostNode extends StatelessWidget {
void redirectToPost(BuildContext context) { void redirectToPost(BuildContext context) {
showDialog( showDialog(
context: context, builder: (_) => new PostNodeDialog(post, trustColor)); context: context,
//Navigator.push( builder: (_) => new PostNodeDialog(post, trustColor),
// context, );
// MaterialPageRoute(
// builder: (context) => PostNodeTooltip(post, this.trustColor),
// ));
} }
} }
class PostNodeDialog extends StatelessWidget { class PostNodeDialog extends StatelessWidget {
PostNodeDialog(this.post, this.trustColor); PostNodeDialog(this.post, this.trustColor,
{this.width = 350, this.height = 400});
final Post post; final Post post;
final Color trustColor; final Color trustColor;
final double titleSize = 22; final double titleSize = 22;
final double width;
final double height;
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
titlePadding: EdgeInsets.all(0), titlePadding: EdgeInsets.all(0),
actions: [
TextButton.icon(
onPressed: () => redirectToCommunityGraph(context),
icon: Icon(Icons.group_work),
label: Text(post.community),
),
SizedBox(width: 16),
TextButton.icon(
onPressed: () => redirectToUserGraph(context),
icon: Icon(Icons.supervised_user_circle_rounded),
label: Text(post.author),
),
],
title: Container( title: Container(
width: width,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blue, color: Colors.blue,
boxShadow: [BoxShadow(blurRadius: 0.2, spreadRadius: 0.2)]), boxShadow: [BoxShadow(blurRadius: 0.2, spreadRadius: 0.2)],
),
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Expanded(
children: [
Container(
child: Text( child: Text(
post.title != "" ? post.title : "Comment", post.title != "" ? post.title : "Comment",
overflow: TextOverflow.fade, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.black, color: Colors.black,
fontSize: titleSize, fontSize: titleSize,
), ),
), ),
//constraints: BoxConstraints.expand(),
),
],
),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 25, 0),
child: TextButton(
onPressed: () => redirectToUserGraph(context),
child: Text(
post.author,
style: TextStyle(
color: Colors.black,
fontSize: titleSize,
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(25, 0, 25, 0),
child: TextButton(
onPressed: () => redirectToCommunityGraph(context),
child: Text(
post.community,
style: TextStyle(
color: Colors.black,
fontSize: titleSize,
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(25, 0, 25, 0),
child: Text(
(post.trust * 100).roundToDouble().toString() + "%",
style: TextStyle(
color: trustColor,
fontSize: titleSize,
),
),
), ),
Padding( IconButton(
padding: const EdgeInsets.fromLTRB(25, 0, 0, 0),
child: Material(
color: Colors.blue,
child: IconButton(
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
icon: Icon( icon: Icon(
Icons.close, Icons.close,
color: Colors.white, color: Colors.white,
), ),
), ),
),
),
],
),
)
], ],
), ),
), ),
content: Column( content: Container(
width: width,
height: height,
child: Column(
children: [ children: [
Column( Expanded(
children: [ child: SingleChildScrollView(
SingleChildScrollView(
child: Container( child: Container(
//constraints: BoxConstraints.expand(),
padding: EdgeInsets.fromLTRB(0, 10, 0, 0), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
child: Text( child: Text(
post.content != "" post.effectiveContent,
? post.content
: "This post only has a title.",
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
style: TextStyle(color: Colors.black, fontSize: 19), style: TextStyle(color: Colors.black, fontSize: 19),
), ),
), ),
), ),
],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text( Text(
post.title != "" ? post.comments.toString() + " Comments" : "", post.title != "" ? "${post.comments} Comments" : "",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
), ),
...@@ -172,10 +129,13 @@ class PostNodeDialog extends StatelessWidget { ...@@ -172,10 +129,13 @@ class PostNodeDialog extends StatelessWidget {
], ],
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
), ),
),
); );
} }
void redirectToUserGraph(BuildContext context) { void redirectToUserGraph(BuildContext context) {
// pop dialog
Navigator.of(context).pop();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
...@@ -184,10 +144,13 @@ class PostNodeDialog extends StatelessWidget { ...@@ -184,10 +144,13 @@ class PostNodeDialog extends StatelessWidget {
} }
void redirectToCommunityGraph(BuildContext context) { void redirectToCommunityGraph(BuildContext context) {
// pop dialog
Navigator.of(context).pop();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => CommunityGraphViewPage(post.community), builder: (context) => CommunityGraphViewPage(post.community),
)); ),
);
} }
} }
...@@ -20,8 +20,6 @@ class MyApp extends StatefulWidget { ...@@ -20,8 +20,6 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
Future<BackendUser> _checkLoginStuff() async { Future<BackendUser> _checkLoginStuff() async {
await Future.delayed(Duration(milliseconds: 500));
try { try {
return await LoginHelper().loggedInUser; return await LoginHelper().loggedInUser;
} on LoginException { } on LoginException {
......
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