Commit df60c4bf authored by Manuel's avatar Manuel

polished post dialog

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