import 'package:app/gapi/client.dart'; import 'package:app/pages/login_page.dart'; import 'package:app/widgets/background.dart'; import 'package:app/widgets/bottom_bar.dart'; import 'package:app/widgets/side_drawer.dart'; import 'package:flutter/material.dart'; import 'dart:core'; class StartPage extends StatefulWidget { StartPage({ super.key, this.client, }); GClient? client; @override State createState() => _StartPageState(); } class _StartPageState extends State { // List _selectedBottomBarButtons = bottomBarButtons; final List bottombarButtons = []; void _init() async { final c = await GClient.client; setState(() { widget.client = c; }); } @override void initState() { _init(); super.initState(); } @override Widget build(BuildContext context) { return Background( child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, ), drawer: 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, ), ], ), ), TextButton( onPressed: () { setState(() { widget.client?.session.accessToken = null; widget.client?.session .removeSession(widget.client!.session.sessionId!); }); }, 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( // onTap: (value) => _bottomBarAction(value), 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: 'Menu', icon: IconButton( onPressed: () { Scaffold.of(context).openDrawer(); }, icon: const Icon( Icons.menu, color: Colors.white, ), ), ) ] : [ BottomNavigationBarItem( label: 'register', backgroundColor: Colors.white, icon: Column( children: [ IconButton( onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => LoginPage())); }, icon: const Icon( Icons.login, color: Colors.white, ), ), const Text( 'Registrieren', style: TextStyle( color: Colors.white, fontSize: 16, ), ) ], ), ), BottomNavigationBarItem( label: 'login', backgroundColor: Colors.white, icon: Column( children: [ IconButton( onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => LoginPage())); }, icon: const Icon( Icons.login, color: Colors.white, ), ), const Text( 'Login', 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, ), ), ), ], ); }), body: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Image( image: AssetImage( 'lib/assets/logo_300x200.png', ), ), const SizedBox( height: 40, ), Text( 'Digitale Spuren auf Knopfdruck entfernen'.toUpperCase(), textAlign: TextAlign.center, style: const TextStyle( fontFamily: 'sans-serif', fontSize: 24, height: 1.6, fontWeight: FontWeight.normal, letterSpacing: 6, ), ), TextButton( onPressed: () async { final s = await widget.client?.session.getSessions(); print('SESSIONS: $s'); }, child: const Text( "GET SESSIONS", ), ), ], ), ), ), ); } }