|
|
@ -1,15 +1,120 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:qr_flutter/qr_flutter.dart'; |
|
|
|
import '/utils/storage/database.dart'; |
|
|
|
import '/models/my_profile.dart'; |
|
|
|
import '/components/custom_circle_avatar.dart'; |
|
|
|
|
|
|
|
class Profile extends StatefulWidget { |
|
|
|
const Profile({Key? key}) : super(key: key); |
|
|
|
final MyProfile profile; |
|
|
|
const Profile({ |
|
|
|
Key? key, |
|
|
|
required this.profile, |
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
@override |
|
|
|
State<Profile> createState() => _ProfileState(); |
|
|
|
} |
|
|
|
|
|
|
|
class _ProfileState extends State<Profile> { |
|
|
|
Widget usernameHeading() { |
|
|
|
return Row( |
|
|
|
children: <Widget> [ |
|
|
|
const CustomCircleAvatar( |
|
|
|
icon: Icon(Icons.person, size: 40), |
|
|
|
imagePath: null, // TODO: Add image here |
|
|
|
radius: 30, |
|
|
|
), |
|
|
|
const SizedBox(width: 20), |
|
|
|
Text( |
|
|
|
widget.profile.username, |
|
|
|
style: const TextStyle( |
|
|
|
fontSize: 25, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
), |
|
|
|
// widget.conversation.admin ? IconButton( |
|
|
|
// iconSize: 20, |
|
|
|
// icon: const Icon(Icons.edit), |
|
|
|
// padding: const EdgeInsets.all(5.0), |
|
|
|
// splashRadius: 25, |
|
|
|
// onPressed: () { |
|
|
|
// // TODO: Redirect to edit screen |
|
|
|
// }, |
|
|
|
// ) : const SizedBox.shrink(), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _profileQrCode() { |
|
|
|
return Container( |
|
|
|
child: QrImage( |
|
|
|
data: 'This is a simple QR code', |
|
|
|
version: QrVersions.auto, |
|
|
|
size: 130, |
|
|
|
gapless: true, |
|
|
|
), |
|
|
|
width: 130, |
|
|
|
height: 130, |
|
|
|
color: Theme.of(context).colorScheme.onPrimary, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget settings() { |
|
|
|
return Align( |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
child: Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
children: [ |
|
|
|
const SizedBox(height: 5), |
|
|
|
TextButton.icon( |
|
|
|
label: const Text( |
|
|
|
'Disappearing Messages', |
|
|
|
style: TextStyle(fontSize: 16) |
|
|
|
), |
|
|
|
icon: const Icon(Icons.timer), |
|
|
|
style: ButtonStyle( |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
foregroundColor: MaterialStateProperty.resolveWith<Color>( |
|
|
|
(Set<MaterialState> states) { |
|
|
|
return Theme.of(context).colorScheme.onBackground; |
|
|
|
}, |
|
|
|
) |
|
|
|
), |
|
|
|
onPressed: () { |
|
|
|
print('Disappearing Messages'); |
|
|
|
} |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget logout() { |
|
|
|
return Align( |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
child: Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
children: [ |
|
|
|
TextButton.icon( |
|
|
|
label: const Text( |
|
|
|
'Logout', |
|
|
|
style: TextStyle(fontSize: 16) |
|
|
|
), |
|
|
|
icon: const Icon(Icons.exit_to_app), |
|
|
|
style: const ButtonStyle( |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
), |
|
|
|
onPressed: () { |
|
|
|
deleteDb(); |
|
|
|
MyProfile.logout(); |
|
|
|
Navigator.pushNamedAndRemoveUntil(context, '/landing', ModalRoute.withName('/landing')); |
|
|
|
} |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Scaffold( |
|
|
@ -23,49 +128,30 @@ class _ProfileState extends State<Profile> { |
|
|
|
padding: const EdgeInsets.only(left: 16,right: 16,top: 10), |
|
|
|
child: Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: <Widget>[ |
|
|
|
const Text("Profile",style: TextStyle(fontSize: 32,fontWeight: FontWeight.bold),), |
|
|
|
Container( |
|
|
|
padding: const EdgeInsets.only(left: 8,right: 8,top: 2,bottom: 2), |
|
|
|
height: 30, |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.circular(30), |
|
|
|
color: Theme.of(context).colorScheme.tertiary |
|
|
|
), |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () { |
|
|
|
deleteDb(); |
|
|
|
MyProfile.logout(); |
|
|
|
Navigator.pushNamedAndRemoveUntil(context, '/landing', ModalRoute.withName('/landing')); |
|
|
|
}, |
|
|
|
child: Row( |
|
|
|
children: <Widget>[ |
|
|
|
Icon( |
|
|
|
Icons.logout, |
|
|
|
color: Theme.of(context).primaryColor, |
|
|
|
size: 20 |
|
|
|
), |
|
|
|
const SizedBox(width: 2,), |
|
|
|
const Text( |
|
|
|
'Logout', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14, |
|
|
|
fontWeight: FontWeight.bold |
|
|
|
) |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
children: const <Widget>[ |
|
|
|
Text( |
|
|
|
'Profile', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 32, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
), |
|
|
|
) |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.only(top: 16,left: 16,right: 16), |
|
|
|
child: Row( |
|
|
|
children: const <Widget>[ |
|
|
|
Text('FUCK'), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
const SizedBox(height: 30), |
|
|
|
usernameHeading(), |
|
|
|
const SizedBox(height: 30), |
|
|
|
_profileQrCode(), |
|
|
|
const SizedBox(height: 30), |
|
|
|
settings(), |
|
|
|
const SizedBox(height: 30), |
|
|
|
logout(), |
|
|
|
], |
|
|
|
) |
|
|
|
), |
|
|
|