Commit 2f86dea6 authored by Inomjon's avatar Inomjon

Aplication webga chiqdi

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