mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 18:47:56 +00:00
profile
This commit is contained in:
@@ -25,7 +25,7 @@ class MenuView extends StatelessWidget {
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
ProfileTab(name:profileBloc.name),
|
||||
ProfileTab(),
|
||||
for (var section in menuSections)
|
||||
MenuList(
|
||||
section: section,
|
||||
|
||||
@@ -1,62 +1,98 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/menu/view/widgets/profile/profile_view.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class ProfileTab extends StatelessWidget {
|
||||
final String? name;
|
||||
const ProfileTab({super.key,this.name});
|
||||
const ProfileTab({super.key, this.name});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
return BlocBuilder<AuthCubit, AuthState>(
|
||||
builder: (context, state) {
|
||||
final user = AuthCubit.user;
|
||||
Uint8List? imageBytes;
|
||||
if (user!.profilePicture != null) {
|
||||
final base64String = user.profilePicture!;
|
||||
final startIndex = base64String.indexOf('base64,') + 7;
|
||||
final pureBase64String = base64String.substring(startIndex);
|
||||
imageBytes = base64.decode(pureBase64String);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileView(),
|
||||
),
|
||||
)
|
||||
.then((result) {
|
||||
if (result == true) {
|
||||
context.read<AuthCubit>().fetchUserInfo();
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
DefaultContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: name!,
|
||||
fontWeight: FontWeight.bold,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
DefaultContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: '${user.firstName!} ',
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
BodyMedium(
|
||||
text: user.lastName!,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
],
|
||||
),
|
||||
const BodySmall(text: "Syncrow Account"),
|
||||
],
|
||||
),
|
||||
BodySmall(text: "Syncrow Account")
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
right: 20,
|
||||
top: 0,
|
||||
child: CircleAvatar(
|
||||
radius: 38,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 37,
|
||||
backgroundColor: Colors.grey,
|
||||
child: ClipOval(
|
||||
child: Image.memory(
|
||||
imageBytes!,
|
||||
fit: BoxFit.cover,
|
||||
width: 110, // You can adjust the width and height as needed
|
||||
height: 110,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
right: 20,
|
||||
top: 0,
|
||||
child: CircleAvatar(
|
||||
radius: 38,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 37,
|
||||
backgroundColor: Colors.grey,
|
||||
child: SyncrowLogo(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_bloc.dart';
|
||||
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_event.dart';
|
||||
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_state.dart';
|
||||
@@ -13,29 +14,29 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ProfileView extends StatelessWidget {
|
||||
const ProfileView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => ProfileBloc(userId: ''),
|
||||
child: BlocConsumer<ProfileBloc, ProfileState>(listener: (context, state) {
|
||||
if (state is FailedState) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.errorMessage),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
create: (BuildContext context) => ProfileBloc()..add(InitialProfileEvent()),
|
||||
child: BlocConsumer<ProfileBloc, ProfileState>(
|
||||
listener: (context, state) {},
|
||||
builder: (context, state) {
|
||||
final profileBloc = BlocProvider.of<ProfileBloc>(context);
|
||||
Uint8List? imageBytes = profileBloc.decodeBase64Image(AuthCubit.user!.profilePicture);
|
||||
return DefaultScaffold(
|
||||
title: 'Syncrow Account',
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: MediaQuery.of(context).size.height*0.05,),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.05,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
profileBloc.add(SelectImageEvent(context: context, isSelected: false));
|
||||
profileBloc.add(
|
||||
SelectImageEvent(context: context, isSelected: false));
|
||||
},
|
||||
child: SizedBox.square(
|
||||
dimension: 125,
|
||||
@@ -48,6 +49,18 @@ class ProfileView extends StatelessWidget {
|
||||
backgroundImage: profileBloc.image == null
|
||||
? null
|
||||
: FileImage(profileBloc.image!),
|
||||
child: profileBloc.image != null
|
||||
? null
|
||||
:imageBytes != null
|
||||
? ClipOval(
|
||||
child: Image.memory(
|
||||
imageBytes,
|
||||
fit: BoxFit.cover,
|
||||
width: 110,
|
||||
height: 110,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -70,7 +83,7 @@ class ProfileView extends StatelessWidget {
|
||||
controller: profileBloc.nameController,
|
||||
enabled: profileBloc.editName,
|
||||
onEditingComplete: () {
|
||||
profileBloc.add(const ChangeNameEvent(value: false));
|
||||
profileBloc.add(SaveNameEvent(context: context));
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Your Name",
|
||||
@@ -98,89 +111,80 @@ class ProfileView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
//Info
|
||||
// Info
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// const BodyMedium(text: 'Email '),
|
||||
// Flexible(
|
||||
// child: TextField(
|
||||
// textAlign: TextAlign.end,
|
||||
// decoration: InputDecoration(
|
||||
// hintText: ' [email protected]',
|
||||
// hintStyle:
|
||||
// context.bodyMedium.copyWith(color: Colors.grey),
|
||||
// border: InputBorder.none,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Container(
|
||||
// height: 1,
|
||||
// color: ColorsManager.greyColor,
|
||||
// ),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const RegionPage(),
|
||||
));
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(text: 'Region '),
|
||||
Flexible(
|
||||
child: BodyMedium(text: 'United Arab Emirates')
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
height: 1,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const TimeZoneScreenPage(),
|
||||
));
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(top: 15, bottom: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(text: 'Time Zone '),
|
||||
Flexible(
|
||||
child: BodyMedium(text: 'GMT +4')
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
vertical: 5,
|
||||
),
|
||||
child:
|
||||
BlocBuilder<AuthCubit, AuthState>(
|
||||
builder: (context, state) {
|
||||
final user = AuthCubit.user;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const RegionPage(),
|
||||
),
|
||||
).then((result) {
|
||||
context.read<AuthCubit>().fetchUserInfo();
|
||||
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyMedium(text: 'Region '),
|
||||
Flexible(child: BodyMedium(text: user!.regionName??'No Region')),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
height: 1,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const TimeZoneScreenPage(),
|
||||
),
|
||||
).then((result) {
|
||||
context.read<AuthCubit>().fetchUserInfo();
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyMedium(text: 'Time Zone '),
|
||||
Flexible(
|
||||
child: BodyMedium(text: user.timeZone??"No Time Zone"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class RegionPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => ProfileBloc(userId: '')..add(RegionInitialEvent()),
|
||||
create: (BuildContext context) => ProfileBloc()..add(RegionInitialEvent()),
|
||||
child: BlocConsumer<ProfileBloc, ProfileState>(listener: (context, state) {
|
||||
if (state is FailedState) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
@@ -15,7 +15,7 @@ class TimeZoneScreenPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => ProfileBloc(userId: '')..add(TimeZoneInitialEvent()),
|
||||
create: (BuildContext context) => ProfileBloc()..add(TimeZoneInitialEvent()),
|
||||
child:
|
||||
BlocConsumer<ProfileBloc, ProfileState>(listener: (context, state) {
|
||||
if (state is FailedState) {
|
||||
@@ -38,6 +38,10 @@ class TimeZoneScreenPage extends StatelessWidget {
|
||||
: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller:profileBloc.searchController ,
|
||||
onChanged: (value) {
|
||||
profileBloc.add(SearchTimeZoneEvent(query: value));
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.search),
|
||||
hintText: 'Search',
|
||||
@@ -59,7 +63,6 @@ class TimeZoneScreenPage extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
|
||||
profileBloc.add(SelectTimeZoneEvent(
|
||||
val: timeZoneList[index].id,
|
||||
context: context));
|
||||
|
||||
Reference in New Issue
Block a user