update personal profile and move edit to menu option
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||||
@@ -141,6 +144,7 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
//print("Here4");
|
//print("Here4");
|
||||||
//print(response.statusCode);
|
//print(response.statusCode);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
@@ -203,6 +207,152 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void editProfileWindow(double width) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => MihPackageWindow(
|
||||||
|
fullscreen: false,
|
||||||
|
windowTitle: "Edit Profile",
|
||||||
|
onWindowTapClose: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
windowBody: Padding(
|
||||||
|
padding:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
MihForm(
|
||||||
|
formKey: _formKey,
|
||||||
|
formFields: [
|
||||||
|
Center(
|
||||||
|
child: MihCircleAvatar(
|
||||||
|
imageFile: propicPreview,
|
||||||
|
width: 150,
|
||||||
|
editable: true,
|
||||||
|
fileNameController: proPicController,
|
||||||
|
userSelectedfile: proPic,
|
||||||
|
frameColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onChange: (selectedImage) {
|
||||||
|
setState(() {
|
||||||
|
proPic = selectedImage;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25.0),
|
||||||
|
Visibility(
|
||||||
|
visible: false,
|
||||||
|
child: MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
controller: proPicController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Selected File Name",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
inputColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
controller: usernameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Username",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateUsername(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
inputColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
controller: fnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "First Name",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
inputColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
controller: lnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Last Name",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihToggle(
|
||||||
|
hintText: "Activate Business Account",
|
||||||
|
initialPostion: businessUser,
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
secondaryFillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onChange: (value) {
|
||||||
|
setState(() {
|
||||||
|
businessUser = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
//Add validation here
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
submitForm();
|
||||||
|
} else {
|
||||||
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Update",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
proPicController.dispose();
|
proPicController.dispose();
|
||||||
@@ -246,22 +396,22 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
return MihSingleChildScroll(
|
return Stack(
|
||||||
child: Padding(
|
children: [
|
||||||
padding: MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
MihSingleChildScroll(
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
child: Padding(
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
padding:
|
||||||
child: Column(
|
MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
children: [
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
MihForm(
|
child: Column(
|
||||||
formKey: _formKey,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
formFields: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: MihCircleAvatar(
|
child: MihCircleAvatar(
|
||||||
imageFile: propicPreview,
|
imageFile: propicPreview,
|
||||||
width: 150,
|
width: 150,
|
||||||
editable: true,
|
editable: false,
|
||||||
fileNameController: proPicController,
|
fileNameController: proPicController,
|
||||||
userSelectedfile: proPic,
|
userSelectedfile: proPic,
|
||||||
frameColor:
|
frameColor:
|
||||||
@@ -275,117 +425,72 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25.0),
|
Text(
|
||||||
Visibility(
|
"@${widget.arguments.signedInUser.username}",
|
||||||
visible: false,
|
style: TextStyle(
|
||||||
child: MihTextFormField(
|
fontSize: 35,
|
||||||
fillColor:
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${widget.arguments.signedInUser.fname} ${widget.arguments.signedInUser.lname}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
businessUser ? "Business" : "Personal",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
inputColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
controller: proPicController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Selected File Name",
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
Text(
|
||||||
fillColor:
|
"This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself",
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
style: TextStyle(
|
||||||
inputColor:
|
fontSize: 15,
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
fontWeight: FontWeight.bold,
|
||||||
controller: usernameController,
|
color:
|
||||||
multiLineInput: false,
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
requiredText: true,
|
),
|
||||||
hintText: "Username",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().validateUsername(value);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
// MihToggle(
|
||||||
MihTextFormField(
|
// hintText: "Activate Business Account",
|
||||||
fillColor:
|
// initialPostion: businessUser,
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
// fillColor:
|
||||||
inputColor:
|
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
// secondaryFillColor:
|
||||||
controller: fnameController,
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
multiLineInput: false,
|
// onChange: (value) {
|
||||||
requiredText: true,
|
// setState(() {
|
||||||
hintText: "First Name",
|
// businessUser = value;
|
||||||
validator: (value) {
|
// });
|
||||||
return MihValidationServices().isEmpty(value);
|
// },
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
inputColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
controller: lnameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Last Name",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihToggle(
|
|
||||||
hintText: "Activate Business Account",
|
|
||||||
initialPostion: businessUser,
|
|
||||||
fillColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
secondaryFillColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
onChange: (value) {
|
|
||||||
setState(() {
|
|
||||||
businessUser = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
// children: [
|
|
||||||
// const Text(
|
|
||||||
// "Activate Business Account",
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// fontSize: 20,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(
|
|
||||||
// width: 10,
|
|
||||||
// ),
|
|
||||||
// Switch(
|
|
||||||
// value: businessUser,
|
|
||||||
// onChanged: (bool value) {
|
|
||||||
// setState(() {
|
|
||||||
// businessUser = value;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
// ),
|
||||||
const SizedBox(height: 30.0),
|
const SizedBox(height: 30.0),
|
||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
//Add validation here
|
// //Add validation here
|
||||||
if (_formKey.currentState!.validate()) {
|
// if (_formKey.currentState!.validate()) {
|
||||||
submitForm();
|
// submitForm();
|
||||||
} else {
|
// } else {
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
// MihAlertServices().formNotFilledCompletely(context);
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
buttonColor:
|
buttonColor:
|
||||||
MzanziInnovationHub.of(context)!.theme.successColor(),
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Update",
|
"Connect",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MzanziInnovationHub.of(context)!
|
color: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
@@ -398,9 +503,36 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
|
right: 5,
|
||||||
|
bottom: 10,
|
||||||
|
child: MihFloatingMenu(
|
||||||
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
|
children: [
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
label: "Edit Profile",
|
||||||
|
labelBackgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
onTap: () {
|
||||||
|
editProfileWindow(width);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user