add logout function 2

setting_branch
enadhilal 5 years ago
parent e9f9879526
commit 3671ade536

@ -76,4 +76,11 @@ class AuthenticationViewModel with ChangeNotifier {
notifyListeners();
}
}
logout() async{
await sharedPref.clear();
isLogin = false;
isLoading = false;
notifyListeners();
}
}

File diff suppressed because one or more lines are too long

@ -1,17 +1,22 @@
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
import 'package:driverapp/root_page.dart';
import 'package:driverapp/uitl/translations_delegate_base.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class SettingPage extends StatelessWidget {
final String driverName;//_authenticationViewModel.user.userName
final String driverName; //_authenticationViewModel.user.userName
final int driverID;
SettingPage({this.driverName, this.driverID});
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
authenticationViewModel = Provider.of(context);
return AppScaffold(
isShowAppBar: true,
appBarColor: Color(0xff30B7B9),
@ -35,38 +40,40 @@ class SettingPage extends StatelessWidget {
maxRadius: 200.0,
child: Image.asset(
'assets/images/driver.png',
height: MediaQuery.of(context).size.width * 1 ,
height: MediaQuery.of(context).size.width * 1,
width: MediaQuery.of(context).size.width * 1,
fit: BoxFit.contain,
),
),
),
),
SizedBox(height: MediaQuery.of(context).size.width *0.05,),
SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
Container(
child: Text(
driverName,
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.white
),
color: Colors.white),
),
),
SizedBox(height: MediaQuery.of(context).size.width *0.05,),
SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
Container(
child: Text(
'ID: ${driverID.toString()}',
style: TextStyle(
fontSize: 20,
color: Colors.white
),
style: TextStyle(fontSize: 20, color: Colors.white),
),
),
],
),
),
SizedBox(height: MediaQuery.of(context).size.width *0.1,),
SizedBox(
height: MediaQuery.of(context).size.width * 0.1,
),
Container(
margin: EdgeInsets.only(left: 35),
child: Column(
@ -85,23 +92,25 @@ class SettingPage extends StatelessWidget {
size: 40,
color: Colors.white,
),
SizedBox(width: MediaQuery.of(context).size.width *0.05,),
SizedBox(
width: MediaQuery.of(context).size.width * 0.05,
),
Text(
TranslationBase.of(context).logout,
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
fontSize: 18
),
fontSize: 18),
),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.width *0.05,
height: MediaQuery.of(context).size.width * 0.05,
child: Center(
child: Container(
margin: EdgeInsetsDirectional.only(start: 0, end: 30),
margin:
EdgeInsetsDirectional.only(start: 0, end: 30),
height: 1.0,
color: Colors.white,
),
@ -109,9 +118,21 @@ class SettingPage extends StatelessWidget {
),
],
),
onTap: (){},
onTap: () async {
await authenticationViewModel.logout();
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => RootPage(),
// ),
// );
// Navigator.of(context).pushNamedAndRemoveUntil(
// '/', ModalRoute.withName('/'));
},
),
SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
SizedBox(height: MediaQuery.of(context).size.width*0.05,),
InkWell(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -133,8 +154,7 @@ class SettingPage extends StatelessWidget {
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
fontSize: 18
),
fontSize: 18),
),
],
),
@ -143,16 +163,19 @@ class SettingPage extends StatelessWidget {
height: 10.0,
child: Center(
child: Container(
margin: EdgeInsetsDirectional.only(start: 0, end: 30),
margin:
EdgeInsetsDirectional.only(start: 0, end: 30),
height: 1.0,
color: Colors.white,
),
),
),
SizedBox(height: MediaQuery.of(context).size.width*0.05,),
SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
],
),
onTap: (){},
onTap: () {},
),
],
),
@ -162,4 +185,4 @@ class SettingPage extends StatelessWidget {
),
);
}
}
}

Loading…
Cancel
Save