You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
5.5 KiB
155 lines
5.5 KiB
import 'dart:async';
|
|
|
|
import 'package:country_list_pick/country_list_pick.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:teso/Classes/TesoUser.dart';
|
|
import 'package:teso/Pages/Sub_Pages/AccountSettings/changePassword.dart';
|
|
import 'package:teso/Pages/Sub_Pages/AccountSettings/genderPicker.dart';
|
|
import 'package:teso/providers/pageAnimations.dart';
|
|
import 'package:teso/providers/user_provider.dart';
|
|
|
|
class AccountSettings extends StatefulWidget {
|
|
@override
|
|
_AccountSettingsState createState() => _AccountSettingsState();
|
|
}
|
|
|
|
class _AccountSettingsState extends State<AccountSettings> {
|
|
bool? show = false;
|
|
|
|
@override
|
|
void initState() {
|
|
SharedPreferences.getInstance().then((value) {
|
|
setState(() {
|
|
show = value.getBool("password");
|
|
});
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
|
return Consumer<UserProvider>(
|
|
builder: (BuildContext context, UserProvider user, Widget? child) {
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height * 0.9,
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: new Wrap(
|
|
children: <Widget>[
|
|
new Container(
|
|
margin: EdgeInsets.only(
|
|
left: 20.0,
|
|
top: 20.0,
|
|
bottom: 12.0,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
child: InkWell(
|
|
onTap: () => Navigator.pop(context),
|
|
child: Icon(Icons.arrow_back_ios),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
width: double.infinity,
|
|
child: Center(
|
|
child: Text(
|
|
"Account Settings",
|
|
style: TextStyle(
|
|
fontSize: 18.0,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
child: Divider(),
|
|
),
|
|
new ListTile(
|
|
trailing: CountryListPick(
|
|
theme: CountryTheme(
|
|
isShowFlag: true, isShowCode: true, isShowTitle: true),
|
|
initialSelection: user.currentUser!.country,
|
|
onChanged: (CountryCode? code) {
|
|
TesoUser newuser = user.currentUser!;
|
|
newuser.country = code!.dialCode;
|
|
Provider.of<UserProvider>(context, listen: false)
|
|
.updateUser(newuser);
|
|
},
|
|
),
|
|
title: new Text('Country'),
|
|
),
|
|
new ListTile(
|
|
trailing: new Wrap(
|
|
spacing: 10,
|
|
children: [
|
|
new Text(
|
|
userProvider.currentUser!.gender!,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Icon(Icons.arrow_forward_ios)
|
|
],
|
|
),
|
|
title: new Text('Gender'),
|
|
onTap: () async {
|
|
int? orientation = 5;
|
|
switch (userProvider.currentUser!.gender) {
|
|
case "Male":
|
|
orientation = 0;
|
|
break;
|
|
case "Female":
|
|
orientation = 1;
|
|
break;
|
|
case "Other":
|
|
orientation = 2;
|
|
break;
|
|
}
|
|
orientation = await (Navigator.push(
|
|
context,
|
|
PageTransition(
|
|
child: Gender(
|
|
value: orientation,
|
|
),
|
|
type: PageTransitionType.leftToRight,
|
|
),
|
|
) as FutureOr<int>);
|
|
TesoUser? newuser = user.currentUser;
|
|
Provider.of<UserProvider>(context, listen: false)
|
|
.updateUser(newuser);
|
|
}),
|
|
Visibility(
|
|
visible: show!,
|
|
child: new ListTile(
|
|
trailing: new Icon(Icons.arrow_forward_ios),
|
|
title: new Text('Change password'),
|
|
onTap: () => Navigator.push(
|
|
context,
|
|
PageTransition(
|
|
child: ChangePassword(),
|
|
type: PageTransitionType.leftToRight,
|
|
),
|
|
)),
|
|
),
|
|
// new ListTile(
|
|
// trailing: new Icon(Icons.arrow_forward_ios),
|
|
// title: new Text('Delete account'),
|
|
// subtitle: new Text(
|
|
// "Delete your account and account data not reversible"),
|
|
// onTap: () => {},
|
|
// ),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|