ft/adds dashboard_page and bugfixes
This commit is contained in:
parent
f41236e304
commit
ab09c558d8
@ -23,7 +23,9 @@ class GClient {
|
|||||||
GClient c = GClient();
|
GClient c = GClient();
|
||||||
c.session = s;
|
c.session = s;
|
||||||
final sessions = await c.session.getSessions();
|
final sessions = await c.session.getSessions();
|
||||||
c.session = sessions[0];
|
if (sessions.isNotEmpty) {
|
||||||
|
c.session = sessions[0];
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +45,9 @@ class GClient {
|
|||||||
session = await Session.newSession;
|
session = await Session.newSession;
|
||||||
|
|
||||||
final sessions = await session.getSessions();
|
final sessions = await session.getSessions();
|
||||||
session = sessions[0];
|
if (sessions.isNotEmpty) {
|
||||||
|
session = sessions[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<CreateAccountResponse> createAccount(
|
Future<CreateAccountResponse> createAccount(
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:app/gapi/client.dart';
|
||||||
import 'package:app/pages/start_page.dart';
|
import 'package:app/pages/start_page.dart';
|
||||||
import 'package:app/widgets/background.dart';
|
import 'package:app/widgets/background.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -43,7 +44,9 @@ void main() async {
|
|||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
)),
|
)),
|
||||||
home: Background(
|
home: Background(
|
||||||
child: StartPage(),
|
child: StartPage(
|
||||||
|
client: await GClient.client,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import 'package:app/gapi/client.dart';
|
import 'package:app/gapi/client.dart';
|
||||||
|
import 'package:app/pages/start_page.dart';
|
||||||
import 'package:app/pb/account_info.pb.dart';
|
import 'package:app/pb/account_info.pb.dart';
|
||||||
import 'package:app/pb/rpc_get_account_info.pb.dart';
|
import 'package:app/pb/rpc_get_account_info.pb.dart';
|
||||||
import 'package:app/widgets/background.dart';
|
import 'package:app/widgets/background.dart';
|
||||||
|
import 'package:app/widgets/bottom_bar.dart';
|
||||||
import 'package:app/widgets/loading_widget.dart';
|
import 'package:app/widgets/loading_widget.dart';
|
||||||
|
import 'package:app/widgets/side_drawer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class DashboardPage extends StatefulWidget {
|
class DashboardPage extends StatefulWidget {
|
||||||
const DashboardPage({super.key, required this.client});
|
const DashboardPage({
|
||||||
|
super.key,
|
||||||
|
required this.client,
|
||||||
|
});
|
||||||
|
|
||||||
final GClient client;
|
final GClient client;
|
||||||
|
|
||||||
@ -27,10 +33,6 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
// if (widget.client.session.accessToken == '') {
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
_setLoading(true);
|
_setLoading(true);
|
||||||
widget.client.getAccountInfo(
|
widget.client.getAccountInfo(
|
||||||
@ -59,7 +61,193 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
height: 80,
|
height: 80,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomBar(),
|
drawer: Builder(builder: (context) {
|
||||||
|
return SideDrawer(
|
||||||
|
children: [
|
||||||
|
const Spacer(),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Scaffold.of(context).closeDrawer();
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'About',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Icon(
|
||||||
|
Icons.question_answer,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Scaffold.of(context).closeDrawer();
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Datenschutz',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Icon(
|
||||||
|
Icons.privacy_tip,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Scaffold.of(context).closeDrawer();
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Impressum',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Icon(
|
||||||
|
Icons.apartment,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.client.session.accessToken != null)
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
widget.client.session.accessToken = null;
|
||||||
|
widget.client.session
|
||||||
|
.removeSession(widget.client.session.sessionId!);
|
||||||
|
|
||||||
|
Navigator.of(context).pop(widget.client);
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Log out',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Icon(
|
||||||
|
Icons.logout,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 250,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
bottomNavigationBar: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
return BottomBar(
|
||||||
|
children: widget.client.session.accessToken != null
|
||||||
|
? [
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
label: 'Personen',
|
||||||
|
icon: Column(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Scaffold.of(context).openDrawer(),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.group,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'Personen',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
label: 'Home',
|
||||||
|
icon: Column(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => StartPage(
|
||||||
|
client: widget.client,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.home,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'Home',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
label: 'Menu',
|
||||||
|
icon: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Scaffold.of(context).openDrawer();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.menu,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
label: 'back',
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
icon: IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.of(context).pop(widget.client),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.arrow_back,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
label: 'Menu',
|
||||||
|
icon: IconButton(
|
||||||
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.menu,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
body: !_loading
|
body: !_loading
|
||||||
? Background(
|
? Background(
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -83,40 +271,3 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BottomBar extends StatelessWidget {
|
|
||||||
const BottomBar({
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BottomNavigationBar(
|
|
||||||
items: [
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
label: 'back',
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
icon: IconButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.arrow_back,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
label: 'Menu',
|
|
||||||
icon: IconButton(
|
|
||||||
onPressed: () => Scaffold.of(context).openDrawer(),
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.person,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -35,7 +35,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
void _bottomBarAction(int index) {
|
void _bottomBarAction(int index) {
|
||||||
switch (bottombarButtons[index].label?.toLowerCase()) {
|
switch (bottombarButtons[index].label?.toLowerCase()) {
|
||||||
case 'back':
|
case 'back':
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
label: 'back',
|
label: 'back',
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
icon: IconButton(
|
icon: IconButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(client),
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.arrow_back,
|
Icons.arrow_back,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:app/gapi/client.dart';
|
import 'package:app/gapi/client.dart';
|
||||||
|
import 'package:app/pages/dashboard_page.dart';
|
||||||
import 'package:app/pages/login_page.dart';
|
import 'package:app/pages/login_page.dart';
|
||||||
import 'package:app/widgets/background.dart';
|
import 'package:app/widgets/background.dart';
|
||||||
import 'package:app/widgets/bottom_bar.dart';
|
import 'package:app/widgets/bottom_bar.dart';
|
||||||
@ -9,10 +10,10 @@ import 'dart:core';
|
|||||||
class StartPage extends StatefulWidget {
|
class StartPage extends StatefulWidget {
|
||||||
StartPage({
|
StartPage({
|
||||||
super.key,
|
super.key,
|
||||||
this.client,
|
required this.client,
|
||||||
});
|
});
|
||||||
|
|
||||||
GClient? client;
|
GClient client;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StartPage> createState() => _StartPageState();
|
State<StartPage> createState() => _StartPageState();
|
||||||
@ -42,88 +43,90 @@ class _StartPageState extends State<StartPage> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
),
|
),
|
||||||
drawer: SideDrawer(children: [
|
drawer: Builder(builder: (context) {
|
||||||
const Spacer(),
|
return SideDrawer(children: [
|
||||||
TextButton(
|
const Spacer(),
|
||||||
onPressed: () {
|
TextButton(
|
||||||
Scaffold.of(context).closeDrawer();
|
onPressed: () {
|
||||||
},
|
Scaffold.of(context).closeDrawer();
|
||||||
child: const Row(
|
},
|
||||||
children: [
|
child: const Row(
|
||||||
Text(
|
children: [
|
||||||
'About',
|
Text(
|
||||||
style: TextStyle(fontSize: 20),
|
'About',
|
||||||
),
|
style: TextStyle(fontSize: 20),
|
||||||
Spacer(),
|
),
|
||||||
Icon(
|
Spacer(),
|
||||||
Icons.question_answer,
|
Icon(
|
||||||
color: Colors.white,
|
Icons.question_answer,
|
||||||
),
|
color: Colors.white,
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
TextButton(
|
||||||
TextButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
Scaffold.of(context).closeDrawer();
|
||||||
Scaffold.of(context).closeDrawer();
|
},
|
||||||
},
|
child: const Row(
|
||||||
child: const Row(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Datenschutz',
|
||||||
'Datenschutz',
|
style: TextStyle(fontSize: 20),
|
||||||
style: TextStyle(fontSize: 20),
|
),
|
||||||
),
|
Spacer(),
|
||||||
Spacer(),
|
Icon(
|
||||||
Icon(
|
Icons.privacy_tip,
|
||||||
Icons.privacy_tip,
|
color: Colors.white,
|
||||||
color: Colors.white,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
TextButton(
|
||||||
TextButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
Scaffold.of(context).closeDrawer();
|
||||||
Scaffold.of(context).closeDrawer();
|
},
|
||||||
},
|
child: const Row(
|
||||||
child: const Row(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Impressum',
|
||||||
'Impressum',
|
style: TextStyle(fontSize: 20),
|
||||||
style: TextStyle(fontSize: 20),
|
),
|
||||||
),
|
Spacer(),
|
||||||
Spacer(),
|
Icon(
|
||||||
Icon(
|
Icons.apartment,
|
||||||
Icons.apartment,
|
color: Colors.white,
|
||||||
color: Colors.white,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
TextButton(
|
||||||
TextButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
setState(() {
|
||||||
setState(() {
|
widget.client?.session.accessToken = null;
|
||||||
widget.client?.session.accessToken = null;
|
widget.client?.session
|
||||||
widget.client?.session
|
.removeSession(widget.client!.session.sessionId!);
|
||||||
.removeSession(widget.client!.session.sessionId!);
|
});
|
||||||
});
|
},
|
||||||
},
|
child: const Row(
|
||||||
child: const Row(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Log out',
|
||||||
'Log out',
|
style: TextStyle(fontSize: 20),
|
||||||
style: TextStyle(fontSize: 20),
|
),
|
||||||
),
|
Spacer(),
|
||||||
Spacer(),
|
Icon(
|
||||||
Icon(
|
Icons.logout,
|
||||||
Icons.logout,
|
color: Colors.white,
|
||||||
color: Colors.white,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
height: 250,
|
||||||
height: 250,
|
)
|
||||||
)
|
]);
|
||||||
]),
|
}),
|
||||||
bottomNavigationBar: Builder(builder: (context) {
|
bottomNavigationBar: Builder(builder: (context) {
|
||||||
return BottomBar(
|
return BottomBar(
|
||||||
// onTap: (value) => _bottomBarAction(value),
|
// onTap: (value) => _bottomBarAction(value),
|
||||||
@ -151,6 +154,44 @@ class _StartPageState extends State<StartPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
label: 'Dashboard',
|
||||||
|
icon: Column(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
// setState(() {
|
||||||
|
|
||||||
|
GClient c = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => DashboardPage(
|
||||||
|
client: widget.client!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
print('Got Client back: $c');
|
||||||
|
// });
|
||||||
|
setState(() {
|
||||||
|
widget.client = c;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.dashboard,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'Dashboard',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
label: 'Menu',
|
label: 'Menu',
|
||||||
@ -172,9 +213,11 @@ class _StartPageState extends State<StartPage> {
|
|||||||
icon: Column(
|
icon: Column(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
widget.client = await Navigator.push(
|
||||||
builder: (context) => LoginPage()));
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => LoginPage()));
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.login,
|
Icons.login,
|
||||||
@ -197,9 +240,11 @@ class _StartPageState extends State<StartPage> {
|
|||||||
icon: Column(
|
icon: Column(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
widget.client = await Navigator.push(
|
||||||
builder: (context) => LoginPage()));
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => LoginPage()));
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.login,
|
Icons.login,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user