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 text;
|
||||||
final String? description;
|
final String? description;
|
||||||
final bool isOther;
|
final bool isOther;
|
||||||
final String image;
|
String image;
|
||||||
|
|
||||||
ItemSelectForm(
|
ItemSelectForm(
|
||||||
this.key,
|
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:cims_apps/features/auth/registration/viewmodel/submission_data_viewmodel.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.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;
|
final String imagePath, content;
|
||||||
|
|
||||||
const DisplayPictureScreen(
|
const DisplayPictureScreen(
|
||||||
{super.key, required this.imagePath, required this.content});
|
{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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List listIcons = [
|
List listIcons = [
|
||||||
|
@ -85,7 +106,7 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: SizeConfig.width,
|
width: SizeConfig.width,
|
||||||
height: SizeConfig.height * .4,
|
height: SizeConfig.height * .4,
|
||||||
child: Image.file(File(imagePath))),
|
child: Image.file(File(widget.imagePath))),
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 16.0),
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -103,7 +124,8 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: List.generate(4, (index) {
|
children: List.generate(4, (index) {
|
||||||
List filteredList = listIcons
|
List filteredList = listIcons
|
||||||
.where((element) => element['key'] == content)
|
.where(
|
||||||
|
(element) => element['key'] == widget.content)
|
||||||
.toList();
|
.toList();
|
||||||
final urlImg = filteredList[index]['urlImg'];
|
final urlImg = filteredList[index]['urlImg'];
|
||||||
final tag = filteredList[index]['tag'];
|
final tag = filteredList[index]['tag'];
|
||||||
|
@ -162,10 +184,10 @@ class DisplayPictureScreen extends StatelessWidget {
|
||||||
provider.initCamera().then((cameras) {
|
provider.initCamera().then((cameras) {
|
||||||
routePush(context,
|
routePush(context,
|
||||||
page: TakePictureScreen(
|
page: TakePictureScreen(
|
||||||
camera: content == 'ktp'
|
camera: widget.content == 'ktp'
|
||||||
? cameras[0]
|
? cameras[0]
|
||||||
: cameras[1],
|
: 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/assets/path_assets.dart';
|
||||||
import 'package:cims_apps/application/component/button/button_view.dart';
|
import 'package:cims_apps/application/component/button/button_view.dart';
|
||||||
import 'package:cims_apps/application/component/image/image_view.dart';
|
import 'package:cims_apps/application/component/image/image_view.dart';
|
||||||
|
@ -16,11 +18,6 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List listImg = [
|
|
||||||
{'urlImg': PathAssets.imgKtpClear, 'tag': 'ID Card'},
|
|
||||||
{'urlImg': PathAssets.imgSelfieClear, 'tag': 'Selfie with ID Card'},
|
|
||||||
];
|
|
||||||
|
|
||||||
bottomSheet() {
|
bottomSheet() {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -87,7 +84,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget photoDocument() {
|
Widget photoDocument(SubmissionDataViewModel provider) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -104,16 +101,21 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: listImg.map((e) {
|
children: provider.listImg.map((e) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: SizeConfig.height * .18,
|
height: SizeConfig.height * .18,
|
||||||
width: SizeConfig.width * .45,
|
width: SizeConfig.width * .45,
|
||||||
child: ImageView(
|
child: ClipRRect(
|
||||||
image: e['urlImg'],
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Image.file(
|
||||||
|
File(e.image),
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
borderRadius: 12,
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return const Icon(Icons.image_not_supported_outlined);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -122,7 +124,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
e['tag'],
|
e.text,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
@ -179,7 +181,7 @@ class SubmitDataIdCard extends StatelessWidget {
|
||||||
color: ColorPalette.slate400,
|
color: ColorPalette.slate400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
photoDocument(),
|
photoDocument(provider),
|
||||||
Container(
|
Container(
|
||||||
width: SizeConfig.width,
|
width: SizeConfig.width,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
|
|
@ -62,7 +62,8 @@ class SubmitEmail extends StatelessWidget {
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
return Consumer<SubmissionDataViewModel>(
|
return Consumer<SubmissionDataViewModel>(
|
||||||
builder: (context, provider, child) {
|
builder: (context, provider, child) {
|
||||||
return Column(
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -73,9 +74,9 @@ class SubmitEmail extends StatelessWidget {
|
||||||
? TextFormView(
|
? TextFormView(
|
||||||
name: 'E-mail Address',
|
name: 'E-mail Address',
|
||||||
hintText: 'Input e-mail address',
|
hintText: 'Input e-mail address',
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
provider.submitEmail();
|
// provider.submitEmail();
|
||||||
},
|
// },
|
||||||
)
|
)
|
||||||
: _emailVerify(),
|
: _emailVerify(),
|
||||||
SizedBox(height: SizeConfig.height * .42),
|
SizedBox(height: SizeConfig.height * .42),
|
||||||
|
@ -90,6 +91,7 @@ class SubmitEmail extends StatelessWidget {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
import 'package:cims_apps/application/component/select_form/select_form_view.dart';
|
import 'package:cims_apps/application/component/select_form/select_form_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class SubmissionDataViewModel extends ChangeNotifier {
|
class SubmissionDataViewModel extends ChangeNotifier {
|
||||||
|
SubmissionDataViewModel() {
|
||||||
|
_getData();
|
||||||
|
}
|
||||||
|
|
||||||
static int _currentStep = 1;
|
static int _currentStep = 1;
|
||||||
int get getCurrentStep => _currentStep;
|
int get getCurrentStep => _currentStep;
|
||||||
int stepAmount = 9;
|
int stepAmount = 9;
|
||||||
|
@ -45,6 +50,11 @@ class SubmissionDataViewModel extends ChangeNotifier {
|
||||||
ItemSelectForm('key5', 'CIMB NIAGA'),
|
ItemSelectForm('key5', 'CIMB NIAGA'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
List<ItemSelectForm> listImg = [
|
||||||
|
ItemSelectForm('', 'ID Card', image: ''),
|
||||||
|
ItemSelectForm('', 'Selfie with ID Card', image: ''),
|
||||||
|
];
|
||||||
|
|
||||||
Future<List<CameraDescription>> initCamera() async {
|
Future<List<CameraDescription>> initCamera() async {
|
||||||
final cameras = await availableCameras();
|
final cameras = await availableCameras();
|
||||||
final camerasDesc = cameras;
|
final camerasDesc = cameras;
|
||||||
|
@ -83,4 +93,15 @@ class SubmissionDataViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
return false;
|
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"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.27.7"
|
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:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -671,4 +727,4 @@ packages:
|
||||||
version: "6.5.0"
|
version: "6.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.3 <4.0.0"
|
dart: ">=3.2.3 <4.0.0"
|
||||||
flutter: ">=3.13.0"
|
flutter: ">=3.16.0"
|
||||||
|
|
|
@ -50,6 +50,7 @@ dependencies:
|
||||||
path: ^1.8.3
|
path: ^1.8.3
|
||||||
syncfusion_flutter_signaturepad: ^24.2.4
|
syncfusion_flutter_signaturepad: ^24.2.4
|
||||||
dotted_border: ^2.1.0
|
dotted_border: ^2.1.0
|
||||||
|
shared_preferences: ^2.2.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user