Commit 2f86dea6 authored by Inomjon's avatar Inomjon

Aplication webga chiqdi

parent dac0c905
......@@ -2,8 +2,10 @@
import 'package:bloc/bloc.dart';
import 'package:connectycube_sdk/connectycube_calls.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/cupertino.dart';
import 'package:meta/meta.dart';
import 'package:vmeeting/service/user_repositores/user_repo.dart';
import 'package:vmeeting/src/controllers/enter_number_cont.dart';
import '../../src/utils/app_utils.dart';
part 'edit_profile_event.dart';
part 'edit_profile_state.dart';
......@@ -16,7 +18,8 @@ class EditProfileBloc extends Bloc<EditProfileEvent, EditProfileState> {
on<EditProfileUpdateEvent>((event, emit) async {
try{
await UserRepository.getInstance().updateUserProfile(event.user ?? CubeUser());
await UserRepository.getInstance().updateUserProfile(event.context,event.user ?? CubeUser());
event.controller?.inputElevatedButton.add(false);
emit(EditProfileLoadedState(user: AppUtils.cubeUser));
}catch(e){
emit(EditProfileExceptionState(message: e.toString()));
......
......@@ -9,8 +9,10 @@ class EditProfileFetchEvent extends EditProfileEvent{
}
class EditProfileUpdateEvent extends EditProfileEvent{
final BuildContext context;
final NumberController? controller;
final CubeUser? user;
EditProfileUpdateEvent({this.user});
EditProfileUpdateEvent({required this.context, this.controller, this.user});
@override
List<Object?> get props => [user];
}
......@@ -145,8 +145,8 @@ class UserRepository {
});
}
Future<void> updateUserProfile(CubeUser user) async {
updateUser(user).then((updatedUser) {
Future<void> updateUserProfile(BuildContext context,CubeUser user) async {
await updateUser(user).then((updatedUser) {
AppUtils.cubeUser = updatedUser;
AppUtils.userModel = UserModel(
login: updatedUser.login ?? "",
......@@ -166,8 +166,9 @@ class UserRepository {
timezone: updatedUser.timeZone.toString(),
twitterId: updatedUser.twitterId ?? "",
updatedAt: updatedUser.updatedAt?.toIso8601String() ?? "",
website: updatedUser.website.toString() ?? ""
website: updatedUser.website.toString(),
);
AppUtils.showSnackBar(context, "The profile has been updated ✅");
}).catchError((error) {});
}
......
import 'package:connectycube_sdk/connectycube_chat.dart';
import 'package:connectycube_sdk/connectycube_sdk.dart';
import 'package:flutter/material.dart';
import 'package:vmeeting/src/extension/context_extensions.dart';
......@@ -73,8 +72,8 @@ class _DrawerMenueState extends State<DrawerMenue> {
child: Column(
children: [
ListTile(
leading: Icon(Icons.settings, color: ColorConst.appBleckColor),
title: const BigText(text: "Settings",),
leading: Icon(Icons.lock, color: ColorConst.appBleckColor),
title: const SmallText(text: "Password changed",size: 16),
trailing: Icon(Icons.navigate_next,
color: ColorConst.appBleckColor,
size: 30,
......
......@@ -141,43 +141,57 @@ class _EditProfilePageState extends State<EditProfilePage> {
],);
}
Widget buildButtons(BuildContext context, CubeUser cubeUser) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: ColorConst.appGreenColor,
disabledForegroundColor: Colors.grey.withOpacity(0.38),
disabledBackgroundColor: Colors.grey.withOpacity(0.12),
),
onPressed: () async {
if(_loginControlle.text.isNotEmpty && _emailControlle.text.isNotEmpty && _fullNameControlle.text.isNotEmpty){
editProfileBloc.add(EditProfileUpdateEvent(
user: CubeUser(
fullName: _fullNameControlle.text,
email: _emailControlle.text,
login: _loginControlle.text,
phone: _phoneControlle.text,
id: cubeUser.id,
)
));
}else{
AppUtils.showSnackBar(context, "PLEASE ENTER THE SAME VALUE AGAIN");
}
return StreamBuilder(stream: widget.controller.outputElevatedButton,
builder: (BuildContext context, snapshot){
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: ColorConst.appGreenColor,
disabledForegroundColor: Colors.grey.withOpacity(0.38),
disabledBackgroundColor: Colors.grey.withOpacity(0.12),
),
onPressed: () async {
if(_loginControlle.text.isNotEmpty && _emailControlle.text.isNotEmpty && _fullNameControlle.text.isNotEmpty){
widget.controller.inputElevatedButton.add(true);
editProfileBloc.add(EditProfileUpdateEvent(
controller: widget.controller,
user: CubeUser(
fullName: _fullNameControlle.text,
email: _emailControlle.text,
login: _loginControlle.text,
phone: _phoneControlle.text,
id: cubeUser.id,
), context: context
));
}else{
AppUtils.showSnackBar(context, "PLEASE ENTER THE SAME VALUE AGAIN");
}
},
child: SizedBox(
height: context.h * 0.06,
child: Center(
child: BigText(
text: "Update".toUpperCase(),
fontWidget: FontWeight.bold,
size: 16,
),
),
),
);
},
child: SizedBox(
height: context.h * 0.06,
child: Center(
child: snapshot.data ?? false
? AppUtils.buttonLoader
: BigText(
text: "Update".toUpperCase(),
fontWidget: FontWeight.bold,
size: 16,
),
),
),
),
],
);
});
}
Widget buildImage(BuildContext context, CubeUser cubeUser) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
......
......@@ -47,11 +47,11 @@ class ProfilePage extends StatelessWidget {
borderRadius: BorderRadius.circular(12)),
child: Center(
child: SmallText(
text: AppUtils.userModel.id.toString() ?? "",
text: "ID: ${AppUtils.userModel.id ?? ""}",
),
),
),
SizedBox(height: context.h * 0.03),
SizedBox(height: context.h * 0.02),
Container(
height: context.h * 0.06,
decoration: BoxDecoration(
......@@ -59,11 +59,11 @@ class ProfilePage extends StatelessWidget {
borderRadius: BorderRadius.circular(12)),
child: Center(
child: SmallText(
text: AppUtils.userModel.fullName ?? "",
text: "Full Name: ${AppUtils.userModel.fullName ?? ""}",
),
),
),
SizedBox(height: context.h * 0.03),
SizedBox(height: context.h * 0.02),
Container(
height: context.h * 0.06,
decoration: BoxDecoration(
......@@ -71,11 +71,11 @@ class ProfilePage extends StatelessWidget {
borderRadius: BorderRadius.circular(12)),
child: Center(
child: SmallText(
text: AppUtils.userModel.email ?? "",
text: "Emile: ${AppUtils.userModel.email ?? " "}",
),
),
),
SizedBox(height: context.h * 0.03),
SizedBox(height: context.h * 0.02),
Container(
height: context.h * 0.06,
decoration: BoxDecoration(
......@@ -83,11 +83,23 @@ class ProfilePage extends StatelessWidget {
borderRadius: BorderRadius.circular(12)),
child: Center(
child: SmallText(
text: result.toString(),
text: "Phone: ${AppUtils.userModel.phone ?? "No phone"}",
),
),
),
SizedBox(height: context.h * 0.1),
SizedBox(height: context.h * 0.02),
Container(
height: context.h * 0.06,
decoration: BoxDecoration(
color: ColorConst.appBackgroundColor,
borderRadius: BorderRadius.circular(12)),
child: Center(
child: SmallText(
text: "Create Date: $result",
),
),
),
SizedBox(height: context.h * 0.05),
buildButtons(context),
],
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment