mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:08:56 +03:30
220 lines
10 KiB
Dart
Executable File
220 lines
10 KiB
Dart
Executable File
// import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart';
|
|
import 'package:cssd/providers/connectivity.dart';
|
|
import 'package:cssd/widgets/Global/internet_error.dart';
|
|
import 'package:cssd/widgets/LabelScreens/Detail/header.dart';
|
|
import 'package:cssd/widgets/MyInfo/input_box.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../config/colors.dart';
|
|
import '../config/routes.dart';
|
|
import '../providers/auth.dart';
|
|
import 'home_screen.dart';
|
|
|
|
class MyInfoScreen extends StatefulWidget {
|
|
// static const route = '/MyInfoScreenRoute';
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _MyInfoScreenState();
|
|
}
|
|
}
|
|
|
|
class _MyInfoScreenState extends State<MyInfoScreen> {
|
|
Map<String, dynamic>? user;
|
|
TextEditingController usernameCTRL = new TextEditingController();
|
|
TextEditingController emailCTRL = new TextEditingController();
|
|
|
|
bool isInit = true;
|
|
|
|
@override
|
|
void didChangeDependencies() async {
|
|
if (isInit) {
|
|
var authObj = Provider.of<Auth>(context, listen: false);
|
|
user = await authObj.getUserData();
|
|
usernameCTRL.text = user!['name'] != null ? user!['name'] : '';
|
|
emailCTRL.text = user!['email'] != null ? user!['email'] : '';
|
|
isInit = false;
|
|
}
|
|
super.didChangeDependencies();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final _media = MediaQuery.of(context);
|
|
final double _devicewidth = _media.size.width;
|
|
final double _deviceBlockSize = _devicewidth / 100;
|
|
return SafeArea(
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
},
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
titleSpacing: -10,
|
|
title: Text(
|
|
'Home',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
backgroundColor: Colors.black,
|
|
leading: IconButton(
|
|
icon: Icon(
|
|
Icons.keyboard_arrow_left,
|
|
color: Colors.white,
|
|
size: 35,
|
|
),
|
|
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
|
|
),
|
|
),
|
|
body: Consumer<ConnectivityProvider>(
|
|
builder: (ct, connection, _) {
|
|
return connection.conStatus != 'offline'
|
|
? isInit
|
|
? Center(
|
|
child: CircularProgressIndicator(
|
|
color: Colors.black,
|
|
),
|
|
)
|
|
: ListView(
|
|
children: <Widget>[
|
|
InfoHeader(
|
|
deviceBlockSize: _deviceBlockSize,
|
|
label: 'My Info',
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
child: Column(
|
|
children: <Widget>[
|
|
InfoInputBox(
|
|
controller: usernameCTRL,
|
|
deviceBlockSize: _deviceBlockSize,
|
|
label: 'Full Name',
|
|
icon: FontAwesomeIcons.alignLeft,
|
|
inputType: TextInputType.text,
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
TextFormField(
|
|
readOnly: true,
|
|
initialValue: user!['cell_number'],
|
|
decoration: InputDecoration(
|
|
icon: Icon(
|
|
Icons.call,
|
|
size: 6 * _deviceBlockSize,
|
|
),
|
|
labelStyle: TextStyle(
|
|
fontWeight: FontWeight.w100,
|
|
fontSize: 4 * _deviceBlockSize,
|
|
),
|
|
labelText: 'Cell Number',
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.symmetric(
|
|
vertical: 2, horizontal: 3),
|
|
),
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w700,
|
|
color: Colors.grey,
|
|
fontSize: 5 * _deviceBlockSize,
|
|
),
|
|
keyboardType: TextInputType.number,
|
|
textInputAction: TextInputAction.next,
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
InfoInputBox(
|
|
controller: emailCTRL,
|
|
deviceBlockSize: _deviceBlockSize,
|
|
label: 'Email Address',
|
|
icon: FontAwesomeIcons.envelope,
|
|
inputType: TextInputType.emailAddress,
|
|
),
|
|
SizedBox(height: 20),
|
|
SelectionItem(
|
|
firstLine: 'CHANGE PASSWORD',
|
|
secondLine: 'Set a new password',
|
|
firstLineColor: Colors.black,
|
|
backgroundColor: kLightGreyBackground,
|
|
onTap: () {
|
|
Navigator.of(context)
|
|
.popAndPushNamed(Routes.rePassScreen);
|
|
// Navigator.push(
|
|
// context,
|
|
// MaterialPageRoute(
|
|
// builder: (context) {
|
|
// return Consumer<Auth>(
|
|
// builder: (ctx, auth, _) {
|
|
// return MyInfoScreen();
|
|
// },
|
|
// );
|
|
// },
|
|
// ),
|
|
// )
|
|
},
|
|
),
|
|
Consumer<Auth>(builder: (context, auth, _) {
|
|
return InkWell(
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 60, vertical: 10),
|
|
margin: EdgeInsets.only(
|
|
top: 20, bottom: 20),
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: Colors.black,
|
|
borderRadius:
|
|
BorderRadius.circular(5),
|
|
),
|
|
child: auth.isloading
|
|
? Center(
|
|
child:
|
|
CircularProgressIndicator(
|
|
color: Colors.white,
|
|
),
|
|
)
|
|
: Text(
|
|
'Save',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize:
|
|
5 * _deviceBlockSize,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
)),
|
|
onTap: () async {
|
|
auth.setLoading();
|
|
await Provider.of<Auth>(context,
|
|
listen: false)
|
|
.setUserData(
|
|
user!['id'],
|
|
usernameCTRL.text,
|
|
emailCTRL.text,
|
|
);
|
|
Navigator.of(context).pop();
|
|
auth.resetLoading();
|
|
Fluttertoast.showToast(
|
|
msg: "Info changed successfully.",
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
gravity: ToastGravity.BOTTOM,
|
|
);
|
|
},
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: ConnectionErrorBox();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|