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.
diplomatic-quarter/lib/pages/insurance/AttachInsuranceCardImageDia...

187 lines
6.3 KiB
Dart

4 years ago
import 'dart:io';
3 years ago
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/bottom_options/BottomSheet.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AttachInsuranceCardImageDialog extends StatefulWidget {
final String name;
final String fileNo;
final Function(File file, String image) image;
const AttachInsuranceCardImageDialog({Key key, this.name, this.fileNo, this.image}) : super(key: key);
4 years ago
@override
_AttachInsuranceCardImageDialogState createState() => _AttachInsuranceCardImageDialogState();
4 years ago
}
class _AttachInsuranceCardImageDialogState extends State<AttachInsuranceCardImageDialog> {
4 years ago
@override
void initState() {
super.initState();
}
String image;
File file;
@override
Widget build(BuildContext context) {
return SimpleDialog(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
TranslationBase.of(context).attachInsuraceImage,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
),
4 years ago
Divider(),
Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Text(
widget.name,
style: TextStyle(
fontSize: 14,
letterSpacing: -0.48,
),
),
),
4 years ago
SizedBox(
height: 3,
),
Text(
TranslationBase.of(context).fileNo + " " + widget.fileNo,
style: TextStyle(
fontSize: 14,
letterSpacing: -0.48,
),
),
4 years ago
SizedBox(
height: 5.0,
),
InkWell(
onTap: () {
ImageOptions.showImageOptions(context, (String image, File file) {
4 years ago
setState(() {
this.image = image;
this.file = file;
});
});
},
child: image == null
? Padding(
padding: const EdgeInsets.all(18.0),
child: Container(
4 years ago
width: double.maxFinite,
height: 250,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(2), border: Border.all(color: Colors.grey, width: 1.5)),
4 years ago
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.,
4 years ago
children: [
SizedBox(
height: 25,
),
4 years ago
Icon(
Icons.camera_enhance_rounded,
size: 85,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.attach_file),
Text(
TranslationBase.of(context).selectAttachment.toUpperCase(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
)
4 years ago
],
),
],
),
),
)
4 years ago
: Image.file(
file,
fit: BoxFit.fill,
height: 250,
4 years ago
),
),
SizedBox(
height: 25.0,
),
Divider(),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Center(
child: Text(
4 years ago
TranslationBase.of(context).cancel.toUpperCase(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
color: Colors.red,
),
4 years ago
),
),
),
),
),
),
Container(
width: 1,
height: 30,
color: Colors.grey[500],
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
3 years ago
if(file != null && image != null) {
Navigator.pop(context);
widget.image(file, image);
} else {
AppToast.showErrorToast(message: TranslationBase.of(context).noInsuranceCardAttached);
}
4 years ago
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(
TranslationBase.of(context).ok.toUpperCase(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
4 years ago
)),
),
),
),
],
)
],
)
],
);
}
}