2023-02-03 03:34:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/src/widgets/framework.dart';
|
|
|
|
import 'package:flutter/src/widgets/placeholder.dart';
|
2023-03-06 00:57:39 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
|
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/references/references_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
2023-02-03 03:34:09 +00:00
|
|
|
import 'package:unit2/model/profile/references.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
2023-02-03 03:34:09 +00:00
|
|
|
import 'package:unit2/theme-data.dart/colors.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/utils/text_container.dart';
|
2023-03-02 00:40:47 +00:00
|
|
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
2023-02-10 07:39:00 +00:00
|
|
|
import 'package:unit2/widgets/empty_data.dart';
|
2023-02-03 03:34:09 +00:00
|
|
|
|
2023-02-10 07:39:00 +00:00
|
|
|
class ReferencesScreen extends StatelessWidget {
|
2023-03-06 00:57:39 +00:00
|
|
|
const ReferencesScreen({super.key});
|
2023-02-03 03:34:09 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-10 07:39:00 +00:00
|
|
|
return Scaffold(
|
2023-03-06 00:57:39 +00:00
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text(referencesScreenTitle),
|
|
|
|
centerTitle: true,
|
|
|
|
backgroundColor: primary,
|
|
|
|
actions: [AddLeading(onPressed: () {})],
|
|
|
|
),
|
|
|
|
body: ProgressHUD(
|
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
backgroundColor: Colors.black87,
|
|
|
|
indicatorWidget: const SpinKitFadingCircle(
|
|
|
|
color: Colors.white),
|
|
|
|
child: BlocBuilder<UserBloc, UserState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
//userbloc
|
|
|
|
if (state is UserLoggedIn) {
|
|
|
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
//profilebloc
|
|
|
|
if (state is ProfileLoaded) {
|
|
|
|
return BlocConsumer<ReferencesBloc, ReferencesState>(
|
|
|
|
//listener
|
|
|
|
listener: (context, state) {
|
|
|
|
if(state is ReferencesLoadingState){
|
|
|
|
final progress = ProgressHUD.of(context);
|
|
|
|
progress!.showWithText("Please wait...");
|
|
|
|
}
|
|
|
|
if(state is ReferencesLoadedState || state is ReferencesErrorState){
|
|
|
|
final progress = ProgressHUD.of(context);
|
|
|
|
progress!.dismiss();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//builder
|
|
|
|
builder: (context, state) {
|
|
|
|
//references bloc
|
|
|
|
if (state is ReferencesLoadedState) {
|
|
|
|
if (state.references.isNotEmpty) {
|
|
|
|
return ListView.builder(
|
2023-02-10 07:39:00 +00:00
|
|
|
padding:
|
2023-03-06 00:57:39 +00:00
|
|
|
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
|
|
|
itemCount: state.references.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
String fullname =
|
|
|
|
"${state.references[index].firstName} ${state.references[index].middleName} ${state.references[index].lastName}";
|
|
|
|
String addres =
|
|
|
|
"${state.references[index].address!.cityMunicipality!.description}, ${state.references[index].address!.cityMunicipality!.province!.description}, ${state.references[0].address!.cityMunicipality!.province!.region!.description}";
|
|
|
|
String mobile = state.references[index].contactNo.toString();
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 12, vertical: 8),
|
|
|
|
decoration: box1(),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(fullname,
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.titleMedium!
|
|
|
|
.copyWith(
|
|
|
|
fontWeight: FontWeight.w500)),
|
|
|
|
const Divider(),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text(addres,
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.titleSmall!
|
|
|
|
.copyWith(
|
|
|
|
fontWeight: FontWeight.w500)),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text("${mobileOrPhone.toUpperCase()} : $mobile",
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.labelMedium!),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {},
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.more_vert,
|
|
|
|
color: Colors.grey,
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
2023-02-10 07:39:00 +00:00
|
|
|
),
|
2023-03-06 00:57:39 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
));
|
2023-02-03 03:34:09 +00:00
|
|
|
}
|
2023-02-10 07:39:00 +00:00
|
|
|
}
|
2023-03-06 00:57:39 +00:00
|
|
|
|