126 lines
4.4 KiB
Dart
126 lines
4.4 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:camerawesome/camerawesome_plugin.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gascom/constants/app_theme.dart';
|
|
import 'package:gascom/screens/success_screen.dart';
|
|
import 'package:gascom/widgets/app_button.dart';
|
|
import 'package:gascom/widgets/custom_app_bar.dart';
|
|
|
|
class DocumentCameraScreen extends StatefulWidget {
|
|
const DocumentCameraScreen({
|
|
super.key,
|
|
required this.title,
|
|
required this.description,
|
|
});
|
|
|
|
final String title;
|
|
final String description;
|
|
|
|
@override
|
|
State<DocumentCameraScreen> createState() => _DocumentCameraScreenState();
|
|
}
|
|
|
|
class _DocumentCameraScreenState extends State<DocumentCameraScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: widget.title,
|
|
),
|
|
body: SafeArea(
|
|
child: CameraAwesomeBuilder.custom(
|
|
sensorConfig: SensorConfig.single(
|
|
aspectRatio: CameraAspectRatios.ratio_16_9,
|
|
flashMode: FlashMode.none,
|
|
sensor: Sensor.position(SensorPosition.back),
|
|
zoom: 0.0,
|
|
),
|
|
saveConfig: SaveConfig.photo(
|
|
|
|
),
|
|
builder: (state, previewSize) {
|
|
return Stack(
|
|
children: [
|
|
Center(
|
|
child: ClipPath(
|
|
clipper: HoleClipper(),
|
|
child: Container(
|
|
color: AppTheme.primaryColor,
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 130,
|
|
left: 20,
|
|
right: 20,
|
|
child: AutoSizeText(
|
|
widget.description,
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
textAlign: TextAlign.center,
|
|
maxLines: 2,
|
|
)
|
|
),
|
|
Positioned(
|
|
bottom: 70,
|
|
left: 20,
|
|
right: 20,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 200,
|
|
child: AppButton(
|
|
onPressed: () {
|
|
// save image as bytes in a variable using the state object
|
|
// state.when(
|
|
// onPhotoMode:(s) => s.takePhoto(
|
|
// onPhoto: (request) => request.when(
|
|
// single: (r) => r.path,
|
|
// ),
|
|
// ),
|
|
// );
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const SuccessScreen(title: 'تم تقديم الطلب بنجاح', subtitle: 'سيتم مراجعة طلبك، واعلامك بموعد الكشف الموقعي',),
|
|
),
|
|
);
|
|
},
|
|
label: "التقاط",
|
|
isElevated: true
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HoleClipper extends CustomClipper<Path> {
|
|
@override
|
|
Path getClip(Size size) {
|
|
final path = Path()
|
|
..addRect(Rect.fromLTWH(0, 0, size.width, size.height))
|
|
..addRRect(RRect.fromRectAndRadius(
|
|
Rect.fromCenter(
|
|
center: Offset(size.width / 2, size.height * 0.38),
|
|
width: size.width - (size.width * 0.2), // Adjust the width of the square
|
|
height: size.height - (size.height * 0.3), // Adjust the height of the square to match the width for a square shape
|
|
),
|
|
const Radius.circular(20), // Adjust the border radius as needed
|
|
))
|
|
..fillType = PathFillType.evenOdd;
|
|
return path;
|
|
}
|
|
|
|
@override
|
|
bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
|
|
return false;
|
|
}
|
|
} |