relatica/lib/screens/profile_screen.dart

57 wiersze
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../controls/app_bottom_nav_bar.dart';
import '../controls/padding.dart';
import '../services/auth_service.dart';
import '../services/setting_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 settings = context.watch<SettingsService>();
final authService = context.watch<AuthService>();
return Scaffold(
appBar: AppBar(
title: Text('Profile'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Checkbox(
value: settings.lowBandwidthMode,
onChanged: (value) =>
settings.lowBandwidthMode = value ?? false,
),
Text('Low Bandwidth Mode'),
],
),
Text(
'Profile: ${authService.currentClient.fold(onSuccess: (client) => client.credentials.handle, onError: (error) => 'Error Getting Profile')}'),
VerticalPadding(),
ElevatedButton(
onPressed: () async {
await authService.signOut();
},
child: Text('Sign Out')),
],
),
),
bottomNavigationBar: AppBottomNavBar(
currentButton: NavBarButtons.profile,
),
);
}
}