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.
HMG_Patient_App/lib/widgets/others/not_auh_page.dart

357 lines
14 KiB
Dart

import 'package:carousel_slider/carousel_slider.dart';
import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/core/model/ImagesInfo.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/Authentication/select_device_imei_res.dart';
import 'package:hmg_patient_app/routes.dart';
import 'package:hmg_patient_app/services/authentication/auth_provider.dart' as auth;
import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/buttons/secondary_button.dart';
import 'package:hmg_patient_app/widgets/data_display/text.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import '../../splashPage.dart';
class NotAutPage extends StatefulWidget {
final String title;
final String? description;
final List<String>? infoList;
final List<ImagesInfo>? imagesInfo;
final String? icon;
NotAutPage({required this.title, this.description, this.infoList, this.imagesInfo, this.icon});
@override
_NotAutPageState createState() => _NotAutPageState();
}
class _NotAutPageState extends State<NotAutPage> {
final authService = new auth.AuthProvider();
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold(
appBarTitle: widget.title,
isShowDecPage: false,
isShowAppBar: true,
showNewAppBar: true,
showNewAppBarTitle: false,
body: Padding(
padding: EdgeInsets.only(bottom: 20, left: 21, right: 21),
child: Column(children: [
Expanded(
child: ListView(
padding: EdgeInsets.zero,
physics: BouncingScrollPhysics(),
children: [
SizedBox(height: 12),
if (widget.icon != null)
Align(
alignment: Alignment.centerLeft,
child: SvgPicture.asset(
widget.icon!,
height: 35,
width: 35,
),
),
SizedBox(height: 16),
Text(
widget.title,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 23 / 24),
),
Text(
widget.description ?? "",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56, height: 21 / 14),
),
SizedBox(
height: 14,
),
if (!projectViewModel.isInternetConnection)
Center(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.55,
width: MediaQuery.of(context).size.width * 0.50,
child: Image.asset(projectViewModel.isArabic ? 'assets/images/Wifi-AR.png' : 'assets/images/wifi-EN.png'),
),
),
if (projectViewModel.isInternetConnection && widget.imagesInfo != null)
CarouselSlider(
items: widget.imagesInfo!.map((image) {
return Builder(
builder: (BuildContext context) {
return SizedBox(
width: MediaQuery.of(context).size.width * 0.50,
child: image.isAsset! ? Image.asset(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!) : Image.network(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!));
},
);
}).toList(),
options: CarouselOptions(
height: MediaQuery.of(context).size.height * 0.55,
autoPlay: widget.imagesInfo!.length > 1,
viewportFraction: 1.0,
),
),
],
),
),
SizedBox(
height: 43,
width: double.infinity,
child: TextButton(
onPressed: () {
loginCheck(context);
},
child: Text(
TranslationBase.of(context).loginregister,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48),
),
style: TextButton.styleFrom(
backgroundColor: Color(0xffD02127),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
),
]),
),
);
// Scaffold(
// backgroundColor: Color(0xfff8f8f8),
// resizeToAvoidBottomInset: false,
// appBar: AppBar(
// backgroundColor: Colors.transparent,
// leading: IconButton(
// icon: Icon(Icons.arrow_back_ios),
// color: Color(0xff2B353E),
// onPressed: () => Navigator.pop(context),
// ),
// ),
// body: Padding(
// padding: EdgeInsets.only(bottom: 20, left: 21, right: 21),
// child: Column(children: [
// Expanded(
// child: ListView(
// padding: EdgeInsets.zero,
// physics: BouncingScrollPhysics(),
// children: [
// SizedBox(height: 12),
// if (widget.icon != null)
// Align(
// alignment: Alignment.centerLeft,
// child: SvgPicture.asset(
// widget.icon!,
// height: 35,
// width: 35,
// ),
// ),
// SizedBox(height: 16),
// Text(
// widget.title,
// style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 23 / 24),
// ),
// Text(
// widget.description!,
// style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56, height: 21 / 14),
// ),
// SizedBox(
// height: 14,
// ),
// if (!projectViewModel.isInternetConnection)
// Center(
// child: SizedBox(
// height: MediaQuery.of(context).size.height * 0.55,
// width: MediaQuery.of(context).size.width * 0.50,
// child: Image.asset(projectViewModel.isArabic ? 'assets/images/Wifi-AR.png' : 'assets/images/wifi-EN.png'),
// ),
// ),
// if (projectViewModel.isInternetConnection && widget.imagesInfo != null)
// CarouselSlider(
// items: widget.imagesInfo?.map((image) {
// return Builder(
// builder: (BuildContext context) {
// return SizedBox(
// width: MediaQuery.of(context).size.width * 0.50,
// child: image.isAsset! ? Image.asset(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!) : Image.network(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!));
// },
// );
// }).toList(),
// options: CarouselOptions(
// height: MediaQuery.of(context).size.height * 0.55,
// autoPlay: widget.imagesInfo!.length > 1,
// viewportFraction: 1.0,
// ),
// ),
// ],
// ),
// ),
// SizedBox(
// height: 43,
// width: double.infinity,
// child: TextButton(
// onPressed: () {
// loginCheck(context);
// },
// child: Text(
// TranslationBase.of(context).loginregister,
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48),
// ),
// style: TextButton.styleFrom(
// backgroundColor: Color(0xffD02127),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(6),
// ),
// )),
// ),
// ]),
// ),
// );
//
// return Scaffold(
// body: SingleChildScrollView(
// padding: EdgeInsets.all(12),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Texts(
// widget.title ?? 'Service',
// fontWeight: FontWeight.w800,
// fontSize: 25,
// bold: true,
// color: Color(0xff60686b),
// ),
// SizedBox(
// height: 12,
// ),
// Texts(
// widget.description ?? 'Description',
// fontWeight: FontWeight.normal,
// fontSize: 17,
// ),
// if (widget.infoList != null)
// SizedBox(
// height: 12,
// ),
// if (widget.infoList != null)
// ...List.generate(
// widget.infoList!.length,
// (index) => Container(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Container(
// width: 40,
// height: 40,
// decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Theme.of(context).primaryColor),
// child: Center(
// child: Texts(
// '${index + 1}',
// color: Colors.white,
// ),
// ),
// ),
// SizedBox(
// width: 6,
// ),
// Expanded(child: Texts('${widget.infoList![index]}'))
// ],
// ),
// SizedBox(
// height: 12,
// ),
// ],
// ),
// ),
// ),
// SizedBox(
// height: 22,
// ),
// if (!projectViewModel.isInternetConnection)
// Center(
// child: SizedBox(
// height: MediaQuery.of(context).size.height * 0.55,
// width: MediaQuery.of(context).size.width * 0.50,
// child: Image.asset(projectViewModel.isArabic ? 'assets/images/Wifi-AR.png' : 'assets/images/wifi-EN.png'),
// ),
// ),
// if (projectViewModel.isInternetConnection && widget.imagesInfo != null)
// CarouselSlider(
// items: widget.imagesInfo!.map((image) {
// return Builder(
// builder: (BuildContext context) {
// return SizedBox(
// width: MediaQuery.of(context).size.width * 0.50,
// child: image.isAsset! ? Image.asset(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!) : Image.network(projectViewModel.isArabic! ? image.imageAr! : image.imageEn!));
// },
// );
// }).toList(),
// options: CarouselOptions(
// height: MediaQuery.of(context).size.height * 0.55,
// autoPlay: widget.imagesInfo!.length > 1,
// viewportFraction: 1.0,
// ),
// ),
// SizedBox(
// height: 77,
// ),
// ],
// ),
// ),
// bottomSheet: Container(
// height: MediaQuery.of(context).size.height * 0.10,
// width: double.infinity,
// child: Column(
// children: <Widget>[
// Container(
// width: MediaQuery.of(context).size.width * 0.9,
// child: SecondaryButton(
// onTap: () {
// loginCheck(context);
// },
// label: TranslationBase.of(context).serviceInformationButton,
// textColor: Theme.of(context).backgroundColor),
// ),
// ],
// ),
// ),
// );
}
loginCheck(context) async {
var data = await sharedPref.getObject(IMEI_USER_DATA);
sharedPref.remove(REGISTER_DATA_FOR_LOGIIN);
if (data != null) {
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
} else {
GifLoaderDialogUtils.showMyDialog(context);
authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES? value) {
GifLoaderDialogUtils.hideDialog(context);
if (value != null) {
sharedPref.setObject(IMEI_USER_DATA, value);
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
} else {
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
});
}
}
}