You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
232 lines
9.7 KiB
Dart
232 lines
9.7 KiB
Dart
import 'package:carousel_slider/carousel_slider.dart';
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
|
|
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
|
|
import 'package:diplomaticquarterapp/models/gradient_color.dart';
|
|
import 'package:diplomaticquarterapp/models/hmg_services.dart';
|
|
import 'package:diplomaticquarterapp/models/slider_data.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/widgets/logged_slider_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/widgets/pharmacy_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/widgets/services_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/widgets/slider_view.dart';
|
|
import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as s;
|
|
import 'package:provider/provider.dart';
|
|
|
|
class LoggedHomePageFragment extends StatefulWidget {
|
|
ProjectViewModel projectViewModel;
|
|
|
|
LoggedHomePageFragment(this.projectViewModel);
|
|
|
|
@override
|
|
_HomePageFragmentState createState() => _HomePageFragmentState();
|
|
}
|
|
|
|
class _HomePageFragmentState extends State<LoggedHomePageFragment> {
|
|
List<HmgServices> hmgServices = [];
|
|
var familyFileProvider = FamilyFilesProvider();
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
initialiseHmgServices(false);
|
|
// getFamilyFiles();
|
|
}
|
|
|
|
initialiseHmgServices(bool isLogin) {
|
|
hmgServices.add(new HmgServices(0, "LiveCare ", "Online Consulting", "assets/images/new/Live_Care.svg", isLogin));
|
|
hmgServices.add(new HmgServices(1, "Covid Test", "Drive-Thru", "assets/images/new/covid_test_drive_thru.svg", isLogin));
|
|
hmgServices.add(new HmgServices(2, "Checkup", "Comprehensive", "assets/images/new/comprehensive_checkup.svg", isLogin));
|
|
hmgServices.add(new HmgServices(3, "HHC Home", "Health Care", "assets/images/new/HHC.svg", isLogin));
|
|
hmgServices.add(new HmgServices(4, "E-Refferal", "Services", "assets/images/new/E_Refferal.svg", isLogin));
|
|
hmgServices.add(new HmgServices(5, "RRT", "Emergency", "assets/images/new/RRT.svg", isLogin));
|
|
}
|
|
|
|
Future<GetAllSharedRecordsByStatusResponse> getFamilyFiles() async {
|
|
if (widget.projectViewModel.user != null) {
|
|
print("calling_family");
|
|
|
|
if (await s.sharedPref.getObject(FAMILY_FILE) != null) {
|
|
// print(await sharedPref.getObject(FAMILY_FILE));
|
|
return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(await s.sharedPref.getObject(FAMILY_FILE)));
|
|
} else {
|
|
return familyFileProvider.getSharedRecordByStatus();
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var appoCountProvider = Provider.of<ToDoCountProviderModel>(context);
|
|
List<Widget> myMedicalList = Utils.myMedicalListHomePage(projectViewModel: widget.projectViewModel, context: context, count: appoCountProvider.count, isLogin: widget.projectViewModel.isLogin);
|
|
return Container(
|
|
width: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
FutureBuilder(
|
|
future: getFamilyFiles(), // async work
|
|
builder: (BuildContext context, AsyncSnapshot<GetAllSharedRecordsByStatusResponse> snapshot) {
|
|
switch (snapshot.connectionState) {
|
|
case ConnectionState.waiting:
|
|
return Padding(padding: EdgeInsets.all(10), child: Text(''));
|
|
default:
|
|
if (snapshot.hasError)
|
|
return Padding(padding: EdgeInsets.all(10), child: Text(snapshot.error));
|
|
else {
|
|
List<SliderData> sliderData = [];
|
|
sliderData.add(new SliderData(TranslationBase.of(context).fileno + ": " + widget.projectViewModel.user.patientID.toString(),
|
|
widget.projectViewModel.user.firstName + ' ' + widget.projectViewModel.user.lastName, "", bannerColor[0].darkColor, bannerColor[0].lightColor));
|
|
for (int i = 0; i < snapshot.data.getAllSharedRecordsByStatusList.length; i++) {
|
|
if (snapshot.data.getAllSharedRecordsByStatusList[i].status == 3)
|
|
sliderData.add(new SliderData(TranslationBase.of(context).fileno + ": " + snapshot.data.getAllSharedRecordsByStatusList[i].responseID.toString(),
|
|
snapshot.data.getAllSharedRecordsByStatusList[i].patientName, "", bannerColor[i + 1].darkColor, bannerColor[i + 1].lightColor));
|
|
}
|
|
|
|
return AspectRatio(
|
|
aspectRatio: 2,
|
|
child: CarouselSlider(
|
|
options: CarouselOptions(
|
|
autoPlay: false,
|
|
enlargeCenterPage: true,
|
|
initialPage: 0,
|
|
aspectRatio: 2.5,
|
|
viewportFraction: 0.9,
|
|
enableInfiniteScroll: false,
|
|
onPageChanged: (index, reason) {
|
|
print("onPageChanged");
|
|
}),
|
|
items: [
|
|
for (int i = 0; i < sliderData.length; i++)
|
|
Builder(
|
|
builder: (BuildContext context) {
|
|
return LoggedSliderView(sliderData[i]);
|
|
},
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
},
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * 0.143,
|
|
child: ListView.separated(
|
|
itemCount: 4,
|
|
padding: EdgeInsets.zero,
|
|
scrollDirection: Axis.horizontal,
|
|
physics: BouncingScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return Container(
|
|
child: myMedicalList[index],
|
|
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: index == 3 ? 20 : 0),
|
|
);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return mWidth(12);
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 20,
|
|
right: 20,
|
|
top: 16,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
mFlex(1),
|
|
Text(
|
|
"View Medical File",
|
|
style: TextStyle(
|
|
color: CustomColors.accentColor,
|
|
fontSize: 14,
|
|
decoration: TextDecoration.underline,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
mHeight(16),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 20, right: 20),
|
|
child: Image.asset("assets/images/bn_offer.png"),
|
|
),
|
|
mHeight(14),
|
|
Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 20,
|
|
right: 20,
|
|
top: 20,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
"HMG Services",
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
"View All Services",
|
|
style: TextStyle(
|
|
color: CustomColors.accentColor,
|
|
decoration: TextDecoration.underline,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
mHeight(20),
|
|
Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * 0.143,
|
|
child: ListView.separated(
|
|
itemCount: hmgServices.length,
|
|
padding: EdgeInsets.zero,
|
|
scrollDirection: Axis.horizontal,
|
|
physics: BouncingScrollPhysics(),
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return Container(
|
|
width: MediaQuery.of(context).size.height * 0.143,
|
|
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: index == hmgServices.length - 1 ? 20 : 0),
|
|
child: ServicesView(hmgServices[index], index),
|
|
);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return mWidth(12);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 20,
|
|
right: 20,
|
|
top: 20,
|
|
),
|
|
child: PharmacyView(),
|
|
),
|
|
mHeight(140),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|