mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 18:48:57 +03:30
Set some save button progress bar and toast message
This commit is contained in:
@@ -4,6 +4,7 @@ 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 '../providers/auth.dart';
|
||||
@@ -23,6 +24,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
TextEditingController emailCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
@@ -48,7 +50,12 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Dashboard', style: TextStyle(color: Colors.white,),),
|
||||
title: Text(
|
||||
'Dashboard',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
@@ -126,55 +133,54 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin:
|
||||
EdgeInsets.only(top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
await Provider.of<Auth>(context,
|
||||
listen: false)
|
||||
.setUserData(
|
||||
user!['id'],
|
||||
usernameCTRL.text,
|
||||
emailCTRL.text,
|
||||
)
|
||||
.then(
|
||||
(value) async => await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(
|
||||
'Info changed successfully.',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
Consumer<Auth>(builder: (context, auth, _) {
|
||||
return InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin: EdgeInsets.only(
|
||||
top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
),
|
||||
child: auth.isloading
|
||||
? Center(
|
||||
child:
|
||||
CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
)
|
||||
: 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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user