Commit 98a145c3 authored by Manuel's avatar Manuel

make-over of community page

parent bc6d5697
<<<<<<< Updated upstream {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\_libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\_libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.5\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-03-11 12:34:54.486234","version":"2.0.1"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-03-09 22:08:04.726748","version":"2.0.1"} \ No newline at end of file
=======
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-03-10 16:07:42.326854","version":"2.0.1"}
>>>>>>> Stashed changes
This diff is collapsed.
...@@ -7,4 +7,9 @@ class Post { ...@@ -7,4 +7,9 @@ class Post {
final String community; final String community;
final double trust; final double trust;
final int comments; final int comments;
String get effectiveTitle {
if (title != null && title.isNotEmpty) return title;
return content;
}
} }
import 'package:apex_flutter_sdk/apex_flutter_sdk.dart';
import 'package:dashboard/main.dart';
import 'package:dashboard/graphing/usergraph.dart'; import 'package:dashboard/graphing/usergraph.dart';
import 'package:dashboard/ui/graphs/community/index.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';
import 'communitygraph.dart';
import '../data/post.dart';
class PostNode extends StatelessWidget { class PostNode extends StatelessWidget {
final Post post; final Post post;
......
import 'package:dashboard/exceptions/login_exception.dart'; import 'package:dashboard/exceptions/login_exception.dart';
import 'package:dashboard/graphing/communitygraph.dart';
import 'package:dashboard/loading.dart'; import 'package:dashboard/loading.dart';
import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/sign_in/loginpage.dart'; import 'package:dashboard/ui/sign_in/loginpage.dart';
import 'package:dashboard/util/loginhelper.dart'; import 'package:dashboard/util/loginhelper.dart';
import 'package:dashboard/util/user.dart'; import 'package:dashboard/util/user.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart'; import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'graphing/usergraph.dart';
import 'graphing/communitygraph.dart';
import 'graphing/communitymetagraph.dart';
void main() { void main() {
runApp(MyApp()); runApp(MyApp());
......
import 'package:dashboard/sign_in/login_form.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
class LoginPage extends StatefulWidget {
LoginPage();
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
String _error;
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: LoginForm(tryLogin, _error),
),
);
}
void tryLogin(String username, String password) async {
await Future.delayed(Duration(seconds: 1));
String json = "{\"username\":\"$username\",\"password\":\"$password\"}";
Future<Map<String, dynamic>> tokenJson = DataGetter.postJson(
"https://articonf1.itec.aau.at:30401/api/tokens", json);
tokenJson.then((value) => Logger().i(value.toString()));
setState(() {
_error = "Test fehlermeldung :)";
});
// tokenJson.then((value) {
// print("bruh");
// Credentials().token = value["token"] as String;
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => CommunityMetaGraphViewPage()));
// }).catchError(
// () {
// print("omegabruh");
// setState(
// () => error = "Wrong Credentials :(",
// );
// },
// );
}
}
import 'dart:math';
import 'package:circlegraph/circlegraph.dart'; import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/querying/datagetter.dart'; import 'package:dashboard/ui/graphs/community/node_community.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../data/community.dart'; import '../../../data/community.dart';
import '../data/communityGraphNodeData.dart'; import '../../../data/communityGraphNodeData.dart';
import '../querying/datagetter.dart'; import '../../../data/post.dart';
import '../data/post.dart'; import '../../../graphing/postnode.dart';
import 'postnode.dart';
import 'communitymetagraph.dart';
class CommunityGraph extends StatefulWidget { class CommunityGraph extends StatefulWidget {
CommunityGraph(this.community); CommunityGraph(this.community, {this.offset = 0});
final Community community; final Community community;
static const int postsPerPage = 21;
final int offset;
_CommunityGraphState createState() => _CommunityGraphState(community); _CommunityGraphState createState() => _CommunityGraphState(community);
} }
...@@ -23,32 +24,36 @@ class _CommunityGraphState extends State<CommunityGraph> { ...@@ -23,32 +24,36 @@ class _CommunityGraphState extends State<CommunityGraph> {
_CommunityGraphState(this.community); _CommunityGraphState(this.community);
final Community community; final Community community;
int nrPerPage = 10;
int pageNr = 0;
build(BuildContext context) { build(BuildContext context) {
var nodes = []; var nodes = [];
for (int i = pageNr * nrPerPage; int startPostIndex = widget.offset;
(i < pageNr * nrPerPage + nrPerPage) && i < community.posts.length; int endPostIndex = min(
i++) { startPostIndex + CommunityGraph.postsPerPage, community.posts.length);
for (int i = startPostIndex; i < endPostIndex; i++) {
nodes.add(community.posts[i]); nodes.add(community.posts[i]);
} }
nodes.add(Post("...", "", "", community.name, community.trust, 69)); nodes.add(
Post("...", "", "", community.name, community.trust, 69),
);
return Container( return Container(
width: 2000, constraints: BoxConstraints.expand(),
height: 1000, child: SingleChildScrollView(
//constraints: BoxConstraints.expand(),
child: InteractiveViewer(
constrained: true,
boundaryMargin: EdgeInsets.all(100),
minScale: 0.01,
maxScale: 5.6,
child: CircleGraph( child: CircleGraph(
radius: 380,
backgroundColor: Color.fromRGBO(55, 57, 46, 1),
root: _getCommunityNode(community), root: _getCommunityNode(community),
children: [for (var node in nodes) _getPostNode(node)], children: [for (var node in nodes) _getPostNode(node)],
edgeColor: Color.fromRGBO(212, 228, 188, 1),
padding: EdgeInsets.zero,
circleLayout: [
Circle(30, 4),
Circle(180, 8),
Circle(380, -1),
],
), ),
), ),
); );
...@@ -59,9 +64,15 @@ class _CommunityGraphState extends State<CommunityGraph> { ...@@ -59,9 +64,15 @@ class _CommunityGraphState extends State<CommunityGraph> {
CommunityGraphNodeData.fromCommunity(community); CommunityGraphNodeData.fromCommunity(community);
return TreeNodeData<CommunityGraphNodeData>( return TreeNodeData<CommunityGraphNodeData>(
child: getCommunityNodeWidget(community.name, community.trust), child: TrustScoreNode(
community.name,
community.trust,
textColor: Color.fromRGBO(212, 228, 188, 1),
icon: Icons.group_work,
),
data: data, data: data,
width: 150, width: 150,
backgroundColor: Color.fromRGBO(34, 42, 104, 1),
); );
} }
...@@ -70,70 +81,16 @@ class _CommunityGraphState extends State<CommunityGraph> { ...@@ -70,70 +81,16 @@ class _CommunityGraphState extends State<CommunityGraph> {
PostNode postNode = PostNode(post); PostNode postNode = PostNode(post);
return TreeNodeData<CommunityGraphNodeData>( return TreeNodeData<CommunityGraphNodeData>(
child: postNode, // child: postNode,
data: data, child: TrustScoreNode(
width: 250, post.effectiveTitle,
); post.trust,
} textColor: Color.fromRGBO(212, 228, 188, 1),
icon: Icons.sticky_note_2,
Widget getCommunityNodeWidget(String name, double trustvalue) {
return Row(
children: [
Expanded(
child: Text(
name,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
),
),
Text(
(trustvalue * 100).toString() + "%",
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.green),
), ),
], data: data,
mainAxisAlignment: MainAxisAlignment.spaceBetween, width: 200,
backgroundColor: Color.fromRGBO(34, 42, 104, 1),
); );
} }
} }
class CommunityGraphViewPage extends StatelessWidget {
final String communityname;
CommunityGraphViewPage(this.communityname);
Widget build(BuildContext context) {
return Scaffold(
appBar: LoggedInAppBar(),
backgroundColor: Colors.white,
floatingActionButton: FloatingActionButton(
onPressed: () => redirectToCommunityMetaGraph(context),
child: Icon(Icons.zoom_out),
),
body: Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Wrap(
children: [],
),
EnhancedFutureBuilder(
future: DataGetter.getCommunity(communityname),
rememberFutureResult: false,
whenDone: (result) => CommunityGraph(result),
whenNotDone: Container(
alignment: Alignment.center, child: Text("Loading..."))),
],
),
));
}
void redirectToCommunityMetaGraph(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommunityMetaGraphViewPage(),
));
}
}
import 'package:dashboard/graphing/communitymetagraph.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/graphs/community/communitygraph.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/material.dart';
class CommunityGraphViewPage extends StatefulWidget {
final String communityname;
CommunityGraphViewPage(this.communityname);
@override
_CommunityGraphViewPageState createState() => _CommunityGraphViewPageState();
}
class _CommunityGraphViewPageState extends State<CommunityGraphViewPage> {
int _startIndex = 0;
int _endIndex = 0;
void initState() {
super.initState();
_endIndex = CommunityGraph.postsPerPage;
}
Widget build(BuildContext context) {
return Scaffold(
appBar: LoggedInAppBar("Community: ${widget.communityname}"),
backgroundColor: Colors.white,
floatingActionButton: Row(
mainAxisSize: MainAxisSize.min,
children: [
FloatingActionButton(
onPressed: () {},
child: Icon(Icons.arrow_left),
),
SizedBox(width: 8),
Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.all(Radius.circular(20)),
),
height: 60,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Post #$_startIndex - #$_endIndex",
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
SizedBox(width: 8),
FloatingActionButton(
onPressed: () {},
child: Icon(Icons.arrow_right),
)
],
),
// FloatingActionButton(
// onPressed: () => redirectToCommunityMetaGraph(context),
// child: Icon(Icons.zoom_out),
// ),
body: EnhancedFutureBuilder(
future: DataGetter.getCommunity(widget.communityname),
rememberFutureResult: false,
whenDone: (result) => CommunityGraph(result),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Posts...",
),
),
),
);
}
void redirectToCommunityMetaGraph(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommunityMetaGraphViewPage(),
));
}
}
import 'package:flutter/material.dart';
class TrustScoreNode extends StatelessWidget {
final String label;
final double trustValue;
final Color textColor;
final IconData icon;
TrustScoreNode(this.label, this.trustValue,
{this.textColor = Colors.black, this.icon});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
if (icon != null)
Icon(
icon,
color: textColor,
),
if (icon != null) SizedBox(width: 4),
Expanded(
child: Text(
label,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.bold,
color: textColor,
),
),
),
Text(
(trustValue * 100).toString() + "%",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
);
}
}
...@@ -3,6 +3,10 @@ import 'package:dashboard/util/loginhelper.dart'; ...@@ -3,6 +3,10 @@ import 'package:dashboard/util/loginhelper.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class LoggedInAppBar extends PreferredSize { class LoggedInAppBar extends PreferredSize {
final String title;
LoggedInAppBar(this.title);
@override @override
Size get preferredSize => Size.fromHeight(60); Size get preferredSize => Size.fromHeight(60);
...@@ -19,6 +23,7 @@ class LoggedInAppBar extends PreferredSize { ...@@ -19,6 +23,7 @@ class LoggedInAppBar extends PreferredSize {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
title: Text(title),
actions: [ actions: [
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
......
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