add logout function 2

setting_branch
enadhilal 6 years ago
parent e9f9879526
commit 3671ade536

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

File diff suppressed because one or more lines are too long

@ -1,8 +1,10 @@
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/uitl/translations_delegate_base.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class SettingPage extends StatelessWidget { class SettingPage extends StatelessWidget {
final String driverName; //_authenticationViewModel.user.userName final String driverName; //_authenticationViewModel.user.userName
@ -10,8 +12,11 @@ class SettingPage extends StatelessWidget {
SettingPage({this.driverName, this.driverID}); SettingPage({this.driverName, this.driverID});
AuthenticationViewModel authenticationViewModel;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
authenticationViewModel = Provider.of(context);
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarColor: Color(0xff30B7B9), appBarColor: Color(0xff30B7B9),
@ -42,31 +47,33 @@ class SettingPage extends StatelessWidget {
), ),
), ),
), ),
SizedBox(height: MediaQuery.of(context).size.width *0.05,), SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
Container( Container(
child: Text( child: Text(
driverName, driverName,
style: TextStyle( style: TextStyle(
fontSize: 40, fontSize: 40,
fontWeight: FontWeight.w600, 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( Container(
child: Text( child: Text(
'ID: ${driverID.toString()}', 'ID: ${driverID.toString()}',
style: TextStyle( style: TextStyle(fontSize: 20, color: Colors.white),
fontSize: 20,
color: Colors.white
),
), ),
), ),
], ],
), ),
), ),
SizedBox(height: MediaQuery.of(context).size.width *0.1,), SizedBox(
height: MediaQuery.of(context).size.width * 0.1,
),
Container( Container(
margin: EdgeInsets.only(left: 35), margin: EdgeInsets.only(left: 35),
child: Column( child: Column(
@ -85,14 +92,15 @@ class SettingPage extends StatelessWidget {
size: 40, size: 40,
color: Colors.white, color: Colors.white,
), ),
SizedBox(width: MediaQuery.of(context).size.width *0.05,), SizedBox(
width: MediaQuery.of(context).size.width * 0.05,
),
Text( Text(
TranslationBase.of(context).logout, TranslationBase.of(context).logout,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.white, color: Colors.white,
fontSize: 18 fontSize: 18),
),
), ),
], ],
), ),
@ -101,7 +109,8 @@ class SettingPage extends StatelessWidget {
height: MediaQuery.of(context).size.width * 0.05, height: MediaQuery.of(context).size.width * 0.05,
child: Center( child: Center(
child: Container( child: Container(
margin: EdgeInsetsDirectional.only(start: 0, end: 30), margin:
EdgeInsetsDirectional.only(start: 0, end: 30),
height: 1.0, height: 1.0,
color: Colors.white, 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( InkWell(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -133,8 +154,7 @@ class SettingPage extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.white, color: Colors.white,
fontSize: 18 fontSize: 18),
),
), ),
], ],
), ),
@ -143,13 +163,16 @@ class SettingPage extends StatelessWidget {
height: 10.0, height: 10.0,
child: Center( child: Center(
child: Container( child: Container(
margin: EdgeInsetsDirectional.only(start: 0, end: 30), margin:
EdgeInsetsDirectional.only(start: 0, end: 30),
height: 1.0, height: 1.0,
color: Colors.white, color: Colors.white,
), ),
), ),
), ),
SizedBox(height: MediaQuery.of(context).size.width*0.05,), SizedBox(
height: MediaQuery.of(context).size.width * 0.05,
),
], ],
), ),
onTap: () {}, onTap: () {},

Loading…
Cancel
Save