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.
159 lines
5.8 KiB
Dart
159 lines
5.8 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: ParkingSlot(model: model),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final vm = context.watch<QrParkingViewModel>(); // عشان loading
|
|
|
|
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),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
/// Bottom button
|
|
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, // control disabled state here
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
borderColor: AppColors.primaryRedColor,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
)
|
|
|
|
// ElevatedButton(
|
|
// style: ElevatedButton.styleFrom(
|
|
// backgroundColor: AppColors.primaryRedColor,
|
|
// shape: RoundedRectangleBorder(
|
|
// borderRadius: BorderRadius.circular(10),
|
|
// ),
|
|
// ),
|
|
// onPressed: vm.isLoading ? null : () => _readQR(context),
|
|
// child: vm.isLoading
|
|
// ? const SizedBox(
|
|
// width: 22,
|
|
// height: 22,
|
|
// child: CircularProgressIndicator(
|
|
// strokeWidth: 2,
|
|
// color: Colors.white,
|
|
// ),
|
|
// )
|
|
// : const Text(
|
|
// "Read Barcodes",
|
|
// style: TextStyle(
|
|
// fontSize: 18,
|
|
// fontWeight: FontWeight.bold,
|
|
// color: Colors.white,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|