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.
252 lines
13 KiB
Dart
252 lines
13 KiB
Dart
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
import 'package:diplomaticquarterapp/core/service/weather_service.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
import 'package:diplomaticquarterapp/models/hmg_services.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/widgets/services_view.dart';
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
import 'package:diplomaticquarterapp/uitl/location_util.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'health-weather/health-weather-indicator.dart';
|
|
|
|
class AllHabibMedicalSevicePage2 extends StatefulWidget {
|
|
@override
|
|
_AllHabibMedicalSevicePage2State createState() => _AllHabibMedicalSevicePage2State();
|
|
}
|
|
|
|
class _AllHabibMedicalSevicePage2State extends State<AllHabibMedicalSevicePage2> {
|
|
List<HmgServices> hmgServices = [];
|
|
LocationUtils locationUtils;
|
|
var weather = '--';
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
AuthenticatedUser authUser = new AuthenticatedUser();
|
|
AuthProvider authProvider = new AuthProvider();
|
|
WeatherService _weatherService = WeatherService();
|
|
double weatherNum = 30;
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
locationUtils = new LocationUtils(isShowConfirmDialog: true, context: context);
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => {Geolocator.getLastKnownPosition().then((value) => setLocation(value))});
|
|
});
|
|
// getPatientAppointmentHistory1();
|
|
// getFamilyFiles();
|
|
}
|
|
|
|
initialiseHmgServices(bool isLogin) {
|
|
hmgServices.clear();
|
|
|
|
hmgServices.add(new HmgServices(0, TranslationBase.of(context).liveCare, TranslationBase.of(context).onlineConsulting, "assets/images/new/Live_Care.svg", isLogin));
|
|
hmgServices.add(new HmgServices(1, TranslationBase.of(context).covidTest, TranslationBase.of(context).driveThru, "assets/images/new/covid_test_drive_thru.svg", isLogin));
|
|
hmgServices.add(new HmgServices(2, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", isLogin));
|
|
hmgServices.add(new HmgServices(3, TranslationBase.of(context).hhcHome, TranslationBase.of(context).healthCare, "assets/images/new/HHC.svg", isLogin));
|
|
hmgServices.add(new HmgServices(4, TranslationBase.of(context).checkup, TranslationBase.of(context).comprehensive, "assets/images/new/comprehensive_checkup.svg", isLogin));
|
|
hmgServices.add(new HmgServices(5, TranslationBase.of(context).emergency, TranslationBase.of(context).services2, "assets/images/new/emergency.svg", isLogin));
|
|
hmgServices.add(new HmgServices(6, TranslationBase.of(context).refferal, TranslationBase.of(context).services2, "assets/images/new/E_Referral.svg", isLogin));
|
|
hmgServices.add(new HmgServices(7, "H\u2082O", TranslationBase.of(context).dailyWater, "assets/images/new/h2o.svg", isLogin));
|
|
hmgServices.add(new HmgServices(8, TranslationBase.of(context).reachUs, TranslationBase.of(context).findUs, "assets/images/new/reach_us.svg", isLogin));
|
|
|
|
hmgServices.add(new HmgServices(9, TranslationBase.of(context).medicalFile, TranslationBase.of(context).My_File_Details, "assets/images/new/medical file.svg", isLogin));
|
|
hmgServices.add(new HmgServices(10, TranslationBase.of(context).book, TranslationBase.of(context).appointment, "assets/images/new/book appointment.svg", isLogin));
|
|
hmgServices.add(new HmgServices(11, TranslationBase.of(context).pharmacy, TranslationBase.of(context).Ecommerce, "assets/images/new/Pharmacy.svg", isLogin));
|
|
hmgServices.add(new HmgServices(12, TranslationBase.of(context).update, TranslationBase.of(context).insuranceCards, "assets/images/new/update insurance card.svg", isLogin));
|
|
hmgServices.add(new HmgServices(13, TranslationBase.of(context).myFamily, TranslationBase.of(context).Family_Files, "assets/images/new/my family.svg", isLogin));
|
|
hmgServices.add(new HmgServices(14, TranslationBase.of(context).My_Child, TranslationBase.of(context).Vaccines, "assets/images/new/child vaccines.svg", isLogin));
|
|
hmgServices.add(new HmgServices(15, TranslationBase.of(context).Todo, TranslationBase.of(context).list, "assets/images/new/todo.svg", isLogin));
|
|
hmgServices.add(new HmgServices(16, TranslationBase.of(context).Blood, TranslationBase.of(context).Donation, "assets/images/new/blood donation.svg", isLogin));
|
|
hmgServices.add(new HmgServices(17, TranslationBase.of(context).Health, TranslationBase.of(context).Calculator, "assets/images/new/health calculator.svg", isLogin));
|
|
hmgServices.add(new HmgServices(18, TranslationBase.of(context).Health, TranslationBase.of(context).Converter, "assets/images/new/health converter.svg", isLogin));
|
|
hmgServices.add(new HmgServices(19, TranslationBase.of(context).Smart, TranslationBase.of(context).Watches, "assets/images/new/smart watch.svg", isLogin));
|
|
hmgServices.add(new HmgServices(20, TranslationBase.of(context).Parking, TranslationBase.of(context).Details, "assets/images/new/parking details.svg", isLogin));
|
|
hmgServices.add(new HmgServices(21, TranslationBase.of(context).Virtual, TranslationBase.of(context).Tour, "assets/images/new/virtual tour.svg", isLogin));
|
|
hmgServices.add(new HmgServices(22, TranslationBase.of(context).News, TranslationBase.of(context).Latest, "assets/images/new/latest news.svg", isLogin));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
initialiseHmgServices(false);
|
|
return AppScaffold(
|
|
isShowAppBar: true,
|
|
isShowDecPage: false,
|
|
showNewAppBar: true,
|
|
showNewAppBarTitle: true,
|
|
appBarTitle: TranslationBase.of(context).alhabiServices,
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
AspectRatio(
|
|
aspectRatio: 1.8,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
decoration: containerRadiusWithGradient(0,
|
|
color1: timeCalculator(6, 0, 10, 59)
|
|
? Color(0xFFB3E3FE)
|
|
: timeCalculator(11, 0, 15, 59)
|
|
? Color(0xFFFF9E7E)
|
|
: Color(0xFF2E6686),
|
|
color2: timeCalculator(6, 0, 10, 59)
|
|
? Color(0xFF9AC7FF)
|
|
: timeCalculator(11, 0, 15, 59)
|
|
? Color(0xFFFECB50)
|
|
: Color(0xFF122F48)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(30.0),
|
|
child: Stack(
|
|
alignment: projectViewModel.isArabic ? Alignment.centerLeft : Alignment.centerRight,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
weather,
|
|
style: TextStyle(
|
|
fontSize: 30,
|
|
letterSpacing: -0.83,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
DateUtil.formatDateToDate(new DateTime.now(), false),
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
letterSpacing: -0.60,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
mFlex(1),
|
|
Text(
|
|
TranslationBase.of(context).healthWeatherIndicators,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
letterSpacing: -0.96,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
TranslationBase.of(context).healthTipsBasedOnCurrentWeather,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
letterSpacing: -0.72,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: HealthWeatherIndicator(),
|
|
),
|
|
);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
|
child: Text(
|
|
TranslationBase.of(context).moreDetails,
|
|
style: TextStyle(fontSize: 12, letterSpacing: -0.72, fontWeight: FontWeight.w600, color: Colors.white, decoration: TextDecoration.underline),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Image.asset(
|
|
"assets/images/Weather_ico.png",
|
|
color: Colors.white.withOpacity(0.5),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
mHeight(16),
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 16,
|
|
right: 16,
|
|
top: 0,
|
|
),
|
|
child: GridView.builder(
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount: hmgServices.length,
|
|
padding: EdgeInsets.zero,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return ServicesView(hmgServices[index], index);
|
|
},
|
|
),
|
|
),
|
|
mHeight(16),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
bool timeCalculator(int startHour, int startMint, int endHour, int endMint) {
|
|
DateTime now = DateTime.now();
|
|
DateTime startDate = DateTime(now.year, now.month, now.day, startHour, startHour);
|
|
DateTime endDate = DateTime(now.year, now.month, now.day, endHour, endMint);
|
|
print(startDate.toString());
|
|
print(endDate.toString());
|
|
print(now);
|
|
print("------------");
|
|
if (startDate.isBefore(now) && endDate.isAfter(now))
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
void setLocation(Position position) {
|
|
this.sharedPref.setDouble(USER_LAT, position.latitude ?? 0.0);
|
|
this.sharedPref.setDouble(USER_LONG, position.longitude ?? 0.0);
|
|
getAuthUser();
|
|
}
|
|
|
|
getAuthUser() async {
|
|
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
|
|
var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE));
|
|
setState(() {
|
|
authUser = data;
|
|
});
|
|
}
|
|
var data = await this.sharedPref.getObject(WEATHER);
|
|
if (data == null) {
|
|
var d = await _weatherService.getWeatherData();
|
|
|
|
print(d);
|
|
weatherNum = d.temperature;
|
|
setState(() {
|
|
weather = d != null ? d.temperature.toString() + '\u2103' : '--';
|
|
});
|
|
} else {
|
|
setState(() {
|
|
weather = data != null ? data['Temperature'].toString() + '\u2103' : '--';
|
|
});
|
|
}
|
|
}
|
|
}
|