fix: submit data id card
This commit is contained in:
parent
9ba8b79112
commit
466d49312d
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
58
pubspec.lock
58
pubspec.lock
|
@ -488,6 +488,62 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.27.7"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.5"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_linux
|
||||
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_web
|
||||
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
shared_preferences_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_windows
|
||||
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -671,4 +727,4 @@ packages:
|
|||
version: "6.5.0"
|
||||
sdks:
|
||||
dart: ">=3.2.3 <4.0.0"
|
||||
flutter: ">=3.13.0"
|
||||
flutter: ">=3.16.0"
|
||||
|
|
|
@ -50,6 +50,7 @@ dependencies:
|
|||
path: ^1.8.3
|
||||
syncfusion_flutter_signaturepad: ^24.2.4
|
||||
dotted_border: ^2.1.0
|
||||
shared_preferences: ^2.2.2
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user