Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:io';
- import 'package:date_format/date_format.dart';
- import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
- import 'package:flutter/material.dart';
- import 'package:font_awesome_flutter/font_awesome_flutter.dart';
- import 'package:intl/intl.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:google_sign_in/google_sign_in.dart';
- import 'package:firebase_auth/firebase_auth.dart';
- import 'package:vivanews/main.dart';
- import 'package:vivanews/util/text_style_util.dart';
- import 'package:vivanews/view/screen/reset_screen.dart';
- import 'package:vivanews/view/screen/updateprofile_screen.dart';
- import 'package:intl/intl.dart';
- class Profile extends StatefulWidget {
- final VoidCallback signOut;
- Profile(this.signOut);
- @override
- _ProfileState createState() => _ProfileState();
- }
- class _ProfileState extends State<Profile> {
- TextEditingController _controllername = new TextEditingController();
- TextEditingController _controllerjk = new TextEditingController();
- TextEditingController _controllertgl = new TextEditingController();
- TextEditingController _controlleremail = new TextEditingController();
- TextEditingController _controllerphone = new TextEditingController();
- TextEditingController _controllerkota = new TextEditingController();
- TextEditingController _controlleraddress = new TextEditingController();
- signOut() {
- setState(() {
- widget.signOut();
- });
- }
- File _image;
- String fullname = "";
- String email = "";
- String phonee = "";
- String avatar = "";
- String city = "";
- String birth_date = "";
- String addresss = "";
- int status;
- int gender;
- // int genderrr;
- getPref() async {
- SharedPreferences preferences = await SharedPreferences.getInstance();
- setState(() {
- fullname = preferences.getString("fullname");
- email = preferences.getString("email");
- phonee = preferences.getString("phone");
- avatar = preferences.getString("avatar");
- city = preferences.getString("city");
- birth_date = preferences.getString("birth_date");
- addresss = preferences.getString("address");
- status = preferences.getInt("status");
- gender = preferences.getInt("gender");
- });
- }
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- getPref();
- }
- @override
- Widget build(BuildContext context) {
- _controllername.text = fullname;
- if (gender == 1) {
- _controllerjk.text = "Laki-Laki";
- } else {
- _controllerjk.text = "Perempuan";
- }
- _controlleremail.text = email;
- _controllerphone.text = phonee;
- _controllerkota.text = city;
- _controlleraddress.text = addresss;
- //DateTime tgl_lahir = DateTime.parse(birth_date);
- String date = birth_date;
- String dateWithT = date.substring(0, 10);
- DateTime dateTime = DateTime.parse(dateWithT);
- _controllertgl.text =
- '${formatDate(dateTime, [dd, '-', mm, '-', yyyy])}';
- final avatar_foto = Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Align(
- alignment: Alignment.center,
- child: CircleAvatar(
- radius: 100,
- backgroundColor: Colors.purple,
- child: ClipOval(
- child: new SizedBox(
- width: 180.0,
- height: 180.0,
- child: (_image != null)
- ? Image.file(
- _image,
- fit: BoxFit.fill,
- )
- : Image.network(
- avatar,
- fit: BoxFit.fill,
- ),
- ),
- ),
- ),
- ),
- ],
- );
- final nama = TextFormField(
- controller: _controllername,
- autofocus: false,
- enabled: false,
- decoration: InputDecoration(
- labelText: 'Nama Lengkap',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final jk = TextFormField(
- controller: _controllerjk,
- enabled: false,
- autofocus: false,
- decoration: InputDecoration(
- labelText: 'Jenis Kelamin',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final tgl = TextFormField(
- controller: _controllertgl,
- enabled: false,
- autofocus: false,
- decoration: InputDecoration(
- labelText: 'Tanggal Lahir',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final emailtext = TextFormField(
- controller: _controlleremail,
- enabled: false,
- autofocus: false,
- decoration: InputDecoration(
- labelText: 'Email',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final phone = TextFormField(
- controller: _controllerphone,
- autofocus: false,
- enabled: false,
- decoration: InputDecoration(
- labelText: 'Nomor Telepon',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final address = TextFormField(
- controller: _controlleraddress,
- autofocus: false,
- enabled: false,
- decoration: InputDecoration(
- labelText: 'Alamat Lengkap',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final kota = TextFormField(
- controller: _controllerkota,
- enabled: false,
- autofocus: false,
- decoration: InputDecoration(
- labelText: 'Kota',
- labelStyle: TextStyleUtil.textStyle(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold
- ),
- ),
- );
- final edit = RaisedButton(
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => UpdateProfile(signOut)),
- );
- },
- color: Colors.purple,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text(
- 'Edit',
- style: TextStyle(fontSize: 18, color: Colors.white),
- ),
- ),
- // elevation: 5,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
- );
- final logout = RaisedButton(
- onPressed: () {
- MyApp().logoutGoogle();
- MyApp().logoutfb();
- signOut();
- },
- color: Colors.purple,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text(
- 'Keluar',
- style: TextStyle(fontSize: 18, color: Colors.white),
- ),
- ),
- // elevation: 5,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
- );
- final resetpass = RaisedButton(
- onPressed: (){
- Navigator.push(context, MaterialPageRoute(builder: (context) => ResetPass()),);
- },
- color: Colors.purple,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text(
- 'Atur Kata Sandi',
- style: TextStyle(fontSize: 18, color: Colors.white),
- ),
- ),
- // elevation: 5,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
- );
- return DefaultTabController(
- length: 4,
- child: Scaffold(
- appBar: new AppBar(
- title: new Text('Profil',
- style: TextStyle(
- fontSize: 20.0,
- color: Colors.purple,
- fontWeight: FontWeight.bold)),
- backgroundColor: Colors.white,
- titleSpacing: -10,
- leading: new IconButton(
- icon: new Icon(Icons.home, color: Colors.purple)),
- actions: <Widget>[
- new IconButton(
- icon: new Icon(FontAwesomeIcons.gift, color: Colors.black)),
- new IconButton(
- icon: new Icon(FontAwesomeIcons.history, color: Colors.black)),
- new IconButton(
- icon: new Icon(FontAwesomeIcons.edit, color: Colors.black)),
- new IconButton(
- onPressed: () {
- MyApp().logoutGoogle();
- MyApp().logoutfb();
- signOut();
- },
- icon:
- new Icon(FontAwesomeIcons.signOutAlt, color: Colors.black))
- ],
- ),
- body: Form(
- child: ListView(
- shrinkWrap: true,
- padding: EdgeInsets.only(left: 24.0, right: 24.0),
- children: <Widget>[
- SizedBox(height: 24.0),
- avatar_foto,
- SizedBox(height: 48.0),
- nama,
- SizedBox(height: 8.0),
- jk,
- SizedBox(height: 8.0),
- tgl,
- SizedBox(height: 8.0),
- emailtext,
- SizedBox(height: 8.0),
- phone,
- SizedBox(height: 8.0),
- address,
- SizedBox(height: 8.0),
- kota,
- SizedBox(height: 24.0),
- edit,
- SizedBox(height: 8.0),
- resetpass,
- SizedBox(height: 8.0),
- logout,
- SizedBox(height: 8.0)
- ],
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement