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.
156 lines
5.2 KiB
Dart
156 lines
5.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
import 'package:hmg_patient_app_new/presentation/parking/parking_slot.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../features/qr_parking/qr_parking_view_model.dart';
|
|
import '../../theme/colors.dart';
|
|
import '../../widgets/appbar/app_bar_widget.dart';
|
|
import '../../widgets/buttons/custom_button.dart';
|
|
import '../../widgets/routes/custom_page_route.dart';
|
|
|
|
|
|
|
|
class ParkingPage extends StatefulWidget {
|
|
const ParkingPage({super.key});
|
|
|
|
@override
|
|
State<ParkingPage> createState() => _ParkingPageState();
|
|
}
|
|
|
|
class _ParkingPageState extends State<ParkingPage> {
|
|
|
|
|
|
Future<void> _readQR(BuildContext context) async {
|
|
final vm = context.read<QrParkingViewModel>();
|
|
final model = await vm.scanAndGetParking();
|
|
if (model == null) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(vm.error ?? "Invalid Qr Code")),
|
|
);
|
|
return;
|
|
}
|
|
|
|
Navigator.of(context).push(
|
|
CustomPageRoute(
|
|
page: ChangeNotifierProvider.value(
|
|
value: vm,
|
|
child: ParkingSlot(model: model),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
final vm = context.read<QrParkingViewModel>();
|
|
await vm.getIsSaveParking();
|
|
if (!mounted) return;
|
|
|
|
if (vm.isSavePark && vm.qrParkingModel != null) {
|
|
Navigator.of(context).push(
|
|
CustomPageRoute(
|
|
page: ChangeNotifierProvider.value(
|
|
value: vm,
|
|
child: ParkingSlot(model: vm.qrParkingModel!),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final vm = context.watch<QrParkingViewModel>();
|
|
return Scaffold(
|
|
backgroundColor: AppColors.scaffoldBgColor,
|
|
appBar: CustomAppBar(
|
|
onBackPressed: () => Navigator.of(context).pop(),
|
|
onLanguageChanged: (_) {},
|
|
hideLogoAndLang: true,
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: EdgeInsets.symmetric(horizontal: 24.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Parking".needTranslation,
|
|
style: TextStyle(
|
|
color: AppColors.textColor,
|
|
fontSize: 27.f,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Container(
|
|
decoration: RoundedRectangleBorder()
|
|
.toSmoothCornerDecoration(
|
|
color: AppColors.whiteColor,
|
|
borderRadius: 24.r,
|
|
hasShadow: true,
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16.h),
|
|
child: Text(
|
|
"Dr. Sulaiman Al Habib hospital are conduction a test for the emerging corona"
|
|
" virus and issuing travel certificates 24/7 in a short time and with high accuracy."
|
|
" Those wishing to benefit from this service can visit one of Dr. Sulaiman Al Habib branches "
|
|
"to conduct a corona test within few minutes. Dr. Sulaiman Al Habib hospital are conduction"
|
|
" a test for the emerging corona virus and issuing travel certificates 24/7 in a short time and with high accuracy. "
|
|
"Those wishing to benefit from this service can visit one of Dr. Sulaiman Al Habib branches to conduct a corona test within few minutes.",
|
|
style: TextStyle(
|
|
color: AppColors.textColor,
|
|
fontSize: 12,
|
|
height: 1.4,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
).paddingOnly(top: 16, bottom: 16),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
Container(
|
|
decoration: RoundedRectangleBorder()
|
|
.toSmoothCornerDecoration(
|
|
color: AppColors.whiteColor,
|
|
borderRadius: 24.r,
|
|
hasShadow: true,
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(24.h),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: CustomButton(
|
|
text: "Read Barcodes".needTranslation,
|
|
onPressed: () => _readQR(context), // always non-null
|
|
isDisabled: vm.isLoading,
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
borderColor: AppColors.primaryRedColor,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|