import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:solaragent/auth.dart'; import 'package:solaragent/screens/about.dart'; import 'package:solaragent/widgets/name_card.dart'; class AccountScreen extends StatefulWidget { const AccountScreen({super.key}); @override State createState() => _AccountScreenState(); } class _AccountScreenState extends State { bool isAuthorized = false; @override void initState() { super.initState(); authClient.isAuthorized().then((value) { setState(() { isAuthorized = value; }); }); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20), child: Column(children: [ Padding( padding: const EdgeInsets.only(top: 20), child: NameCard( onLogin: () async { await authClient.login(context); var authorized = await authClient.isAuthorized(); setState(() { isAuthorized = authorized; }); }, ), ), Padding( padding: const EdgeInsets.only(top: 5), child: Wrap( spacing: 5, children: [ FutureBuilder( future: authClient.isAuthorized(), builder: (BuildContext context, AsyncSnapshot snapshot) { return (snapshot.hasData && snapshot.data == true) ? InkWell( borderRadius: const BorderRadius.all(Radius.circular(40)), splashColor: Colors.indigo.withAlpha(30), onTap: () async { authClient.logout(); var authorized = await authClient.isAuthorized(); setState(() { isAuthorized = authorized; }); }, child: const ListTile( leading: Icon(Icons.logout), title: Text('Logout'), ), ) : Container(); }, ), InkWell( borderRadius: const BorderRadius.all(Radius.circular(40)), splashColor: Colors.indigo.withAlpha(30), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const AboutScreen(), )); }, child: const ListTile( leading: Icon(Icons.info_outline), title: Text('About'), ), ), ], ), ), ]), ), ), ); } }