mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 21:43:31 +00:00
58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:relatica/controls/padding.dart';
|
|
import 'package:relatica/routes.dart';
|
|
|
|
import '../controls/standard_appbar.dart';
|
|
import '../globals.dart';
|
|
import '../services/auth_service.dart';
|
|
|
|
class ProfileScreen extends StatefulWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
State<ProfileScreen> createState() => _ProfileScreenState();
|
|
}
|
|
|
|
class _ProfileScreenState extends State<ProfileScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final authService = context.watch<AccountsService>();
|
|
if (!authService.loggedIn) {
|
|
return Scaffold(
|
|
appBar: StandardAppBar.build(context, 'Not Logged In'),
|
|
body: Center(
|
|
child: Text('Not logged in'),
|
|
));
|
|
}
|
|
final profile = authService.currentProfile;
|
|
return Scaffold(
|
|
appBar: StandardAppBar.build(context, 'Profile'),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text('Profile: ${profile.handle}'),
|
|
const VerticalPadding(),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
final confirm =
|
|
await showYesNoDialog(context, 'Log out account?');
|
|
if (confirm == true) {
|
|
await getIt<AccountsService>().signOut(profile);
|
|
}
|
|
},
|
|
child: const Text('Logout')),
|
|
const VerticalPadding(),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
context.pushNamed(ScreenPaths.switchProfiles);
|
|
},
|
|
child: const Text('Switch Profile'))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|