Commit df60c4bf authored by Manuel's avatar Manuel

polished post dialog

parent 1a3d8c05
...@@ -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,145 +36,106 @@ class PostNode extends StatelessWidget { ...@@ -37,145 +36,106 @@ 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: [ child: Text(
Container( post.title != "" ? post.title : "Comment",
child: Text( overflow: TextOverflow.ellipsis,
post.title != "" ? post.title : "Comment", style: TextStyle(
overflow: TextOverflow.fade, fontWeight: FontWeight.bold,
style: TextStyle( color: Colors.black,
fontWeight: FontWeight.bold, fontSize: titleSize,
color: Colors.black,
fontSize: titleSize,
),
),
//constraints: BoxConstraints.expand(),
), ),
], ),
), ),
Container( IconButton(
margin: EdgeInsets.fromLTRB(10, 0, 5, 0), onPressed: () => Navigator.pop(context),
child: Row( icon: Icon(
mainAxisAlignment: MainAxisAlignment.spaceBetween, Icons.close,
children: [ color: Colors.white,
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).toString() + "%",
style: TextStyle(
color: trustColor,
fontSize: titleSize,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(25, 0, 0, 0),
child: Material(
color: Colors.blue,
child: IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(
Icons.close,
color: Colors.white,
),
),
),
),
],
), ),
) ),
], ],
), ),
), ),
content: Column( content: Container(
children: [ width: width,
Column( height: height,
children: [ child: Column(
SingleChildScrollView( children: [
Expanded(
child: 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
: "There is nothing here :(",
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} Comments" : "",
post.title != "" ? post.comments.toString() + " Comments" : "", textAlign: TextAlign.right,
textAlign: TextAlign.right, style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: 16), ),
), ],
], )
) ],
], 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),
)); ),
);
} }
} }
...@@ -18,8 +18,6 @@ class MyApp extends StatefulWidget { ...@@ -18,8 +18,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