fix: submit data id card
This commit is contained in:
@@ -9,7 +9,7 @@ class ItemSelectForm {
|
||||
final String text;
|
||||
final String? description;
|
||||
final bool isOther;
|
||||
final String image;
|
||||
String image;
|
||||
|
||||
ItemSelectForm(
|
||||
this.key,
|
||||
|
||||
@@ -11,13 +11,34 @@ import 'package:cims_apps/features/auth/registration/view/submission_data/submis
|
||||
import 'package:cims_apps/features/auth/registration/viewmodel/submission_data_viewmodel.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class DisplayPictureScreen extends StatelessWidget {
|
||||
class DisplayPictureScreen extends StatefulWidget {
|
||||
final String imagePath, content;
|
||||
|
||||
const DisplayPictureScreen(
|
||||
{super.key, required this.imagePath, required this.content});
|
||||
|
||||
@override
|
||||
State<DisplayPictureScreen> createState() => _DisplayPictureScreenState();
|
||||
}
|
||||
|
||||
class _DisplayPictureScreenState extends State<DisplayPictureScreen> {
|
||||
Future<void> saveData() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (widget.content == 'ktp') {
|
||||
prefs.setString('imagePath', widget.imagePath);
|
||||
} else {
|
||||
prefs.setString('imagePathSelfie', widget.imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
saveData();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List listIcons = [
|
||||
@@ -85,7 +106,7 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||
SizedBox(
|
||||
width: SizeConfig.width,
|
||||
height: SizeConfig.height * .4,
|
||||
child: Image.file(File(imagePath))),
|
||||
child: Image.file(File(widget.imagePath))),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Text(
|
||||
@@ -103,7 +124,8 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||
runSpacing: 8,
|
||||
children: List.generate(4, (index) {
|
||||
List filteredList = listIcons
|
||||
.where((element) => element['key'] == content)
|
||||
.where(
|
||||
(element) => element['key'] == widget.content)
|
||||
.toList();
|
||||
final urlImg = filteredList[index]['urlImg'];
|
||||
final tag = filteredList[index]['tag'];
|
||||
@@ -162,10 +184,10 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||
provider.initCamera().then((cameras) {
|
||||
routePush(context,
|
||||
page: TakePictureScreen(
|
||||
camera: content == 'ktp'
|
||||
camera: widget.content == 'ktp'
|
||||
? cameras[0]
|
||||
: cameras[1],
|
||||
takeContent: content,
|
||||
takeContent: widget.content,
|
||||
));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cims_apps/application/assets/path_assets.dart';
|
||||
import 'package:cims_apps/application/component/button/button_view.dart';
|
||||
import 'package:cims_apps/application/component/image/image_view.dart';
|
||||
@@ -16,11 +18,6 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List listImg = [
|
||||
{'urlImg': PathAssets.imgKtpClear, 'tag': 'ID Card'},
|
||||
{'urlImg': PathAssets.imgSelfieClear, 'tag': 'Selfie with ID Card'},
|
||||
];
|
||||
|
||||
bottomSheet() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
@@ -87,7 +84,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget photoDocument() {
|
||||
Widget photoDocument(SubmissionDataViewModel provider) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -104,16 +101,21 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: listImg.map((e) {
|
||||
children: provider.listImg.map((e) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: SizeConfig.height * .18,
|
||||
width: SizeConfig.width * .45,
|
||||
child: ImageView(
|
||||
image: e['urlImg'],
|
||||
fit: BoxFit.fill,
|
||||
borderRadius: 12,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(e.image),
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Icon(Icons.image_not_supported_outlined);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@@ -122,7 +124,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
e['tag'],
|
||||
e.text,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
@@ -179,7 +181,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||
color: ColorPalette.slate400,
|
||||
),
|
||||
),
|
||||
photoDocument(),
|
||||
photoDocument(provider),
|
||||
Container(
|
||||
width: SizeConfig.width,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
|
||||
@@ -62,34 +62,36 @@ class SubmitEmail extends StatelessWidget {
|
||||
builder: (context, child) {
|
||||
return Consumer<SubmissionDataViewModel>(
|
||||
builder: (context, provider, child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
!provider.isEmailVerify
|
||||
? const TextCaption(title: 'Enter your e-mail')
|
||||
: const TextCaption(title: 'Check your e-mail '),
|
||||
!provider.isEmailVerify
|
||||
? TextFormView(
|
||||
name: 'E-mail Address',
|
||||
hintText: 'Input e-mail address',
|
||||
onTap: () {
|
||||
provider.submitEmail();
|
||||
},
|
||||
)
|
||||
: _emailVerify(),
|
||||
SizedBox(height: SizeConfig.height * .42),
|
||||
ButtonView(
|
||||
name: 'Next',
|
||||
onPressed: () async {
|
||||
await provider.next(context).then((value) {
|
||||
if (value) {
|
||||
routePush(context, page: const SubmissionParent());
|
||||
}
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
!provider.isEmailVerify
|
||||
? const TextCaption(title: 'Enter your e-mail')
|
||||
: const TextCaption(title: 'Check your e-mail '),
|
||||
!provider.isEmailVerify
|
||||
? TextFormView(
|
||||
name: 'E-mail Address',
|
||||
hintText: 'Input e-mail address',
|
||||
// onTap: () {
|
||||
// provider.submitEmail();
|
||||
// },
|
||||
)
|
||||
: _emailVerify(),
|
||||
SizedBox(height: SizeConfig.height * .42),
|
||||
ButtonView(
|
||||
name: 'Next',
|
||||
onPressed: () async {
|
||||
await provider.next(context).then((value) {
|
||||
if (value) {
|
||||
routePush(context, page: const SubmissionParent());
|
||||
}
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:cims_apps/application/component/select_form/select_form_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SubmissionDataViewModel extends ChangeNotifier {
|
||||
SubmissionDataViewModel() {
|
||||
_getData();
|
||||
}
|
||||
|
||||
static int _currentStep = 1;
|
||||
int get getCurrentStep => _currentStep;
|
||||
int stepAmount = 9;
|
||||
@@ -45,6 +50,11 @@ class SubmissionDataViewModel extends ChangeNotifier {
|
||||
ItemSelectForm('key5', 'CIMB NIAGA'),
|
||||
];
|
||||
|
||||
List<ItemSelectForm> listImg = [
|
||||
ItemSelectForm('', 'ID Card', image: ''),
|
||||
ItemSelectForm('', 'Selfie with ID Card', image: ''),
|
||||
];
|
||||
|
||||
Future<List<CameraDescription>> initCamera() async {
|
||||
final cameras = await availableCameras();
|
||||
final camerasDesc = cameras;
|
||||
@@ -83,4 +93,15 @@ class SubmissionDataViewModel extends ChangeNotifier {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> _getData() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? imagePath = prefs.getString('imagePath');
|
||||
String? imagePathSelfie = prefs.getString('imagePathSelfie');
|
||||
if (imagePath != null && imagePathSelfie != null) {
|
||||
listImg[0].image = imagePath;
|
||||
listImg[1].image = imagePathSelfie;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user