From 2d780c3739859e6ddb40667620a4633eb6718019 Mon Sep 17 00:00:00 2001 From: wibias fuad Date: Tue, 25 May 2021 20:38:28 +0700 Subject: [PATCH] ngepull data pendukung punya aan, udah bikin radiobutton dan validasi nya --- .dart_tool/package_config.json | 8 +- .dart_tool/package_config_subset | 4 + .flutter-plugins-dependencies | 2 +- .packages | 3 +- lib/assets/colors.dart | 1 + lib/main.dart | 3 +- lib/pages/kyc/biodata_pendukung.dart | 284 ++++++++++++++++----------- pubspec.lock | 7 + pubspec.yaml | 1 + 9 files changed, 196 insertions(+), 117 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index b8fe7b8..f138b6f 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -283,6 +283,12 @@ "packageUri": "lib/", "languageVersion": "2.0" }, + { + "name": "grouped_checkbox", + "rootUri": "file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/grouped_checkbox-1.0.0", + "packageUri": "lib/", + "languageVersion": "2.1" + }, { "name": "html", "rootUri": "file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.15.0", @@ -668,7 +674,7 @@ "languageVersion": "2.7" } ], - "generated": "2021-05-23T20:57:01.676757Z", + "generated": "2021-05-24T15:17:07.761125Z", "generator": "pub", "generatorVersion": "2.12.2" } diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index a58ec03..147800d 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -174,6 +174,10 @@ graphs 2.0 file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/ file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/lib/ +grouped_checkbox +2.1 +file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/grouped_checkbox-1.0.0/ +file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/grouped_checkbox-1.0.0/lib/ html 2.12 file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.15.0/ diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 19fd0f0..376dfdd 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-24 04:16:34.088508","version":"2.0.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-25 00:43:12.034793","version":"2.0.3"} \ No newline at end of file diff --git a/.packages b/.packages index 3fbd81f..6c57fc5 100644 --- a/.packages +++ b/.packages @@ -3,7 +3,7 @@ # # For more info see: https://dart.dev/go/dot-packages-deprecation # -# Generated by pub on 2021-05-24 03:57:01.611759. +# Generated by pub on 2021-05-24 22:17:07.567107. _fe_analyzer_shared:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-14.0.0/lib/ analyzer:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/ args:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.0.0/lib/ @@ -51,6 +51,7 @@ flutter_web_plugins:file:///C:/flutter/flutter/packages/flutter_web_plugins/lib/ glob:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/glob-2.0.1/lib/ google_fonts:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-2.0.0/lib/ graphs:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/lib/ +grouped_checkbox:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/grouped_checkbox-1.0.0/lib/ html:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.15.0/lib/ http:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.0/lib/ http_multi_server:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.2.0/lib/ diff --git a/lib/assets/colors.dart b/lib/assets/colors.dart index 2fba40e..bd1a5a5 100644 --- a/lib/assets/colors.dart +++ b/lib/assets/colors.dart @@ -24,6 +24,7 @@ const gray5 = Color.fromRGBO(224, 224, 224, 1.0); // Element Colors const red1 = Color.fromRGBO(159, 25, 25, 1.0); +const formError = Color.fromRGBO(211, 47, 47, 1.0); const info = Color.fromRGBO(151, 182, 255, 1.0); // Color for Akun diff --git a/lib/main.dart b/lib/main.dart index 16b8fe7..00f9b43 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:fundex_app/pages/kyc/biodata_pendukung.dart'; import 'package:fundex_app/pages/register/register.dart'; void main() { - runApp(MaterialApp(home: RegisterPage())); + runApp(MaterialApp(home: DataPendukung())); } class MyApp extends StatelessWidget { diff --git a/lib/pages/kyc/biodata_pendukung.dart b/lib/pages/kyc/biodata_pendukung.dart index 49825f2..122a984 100644 --- a/lib/pages/kyc/biodata_pendukung.dart +++ b/lib/pages/kyc/biodata_pendukung.dart @@ -4,17 +4,18 @@ import 'package:fundex_app/main-screen.dart'; import 'package:fundex_app/pages/kyc/data_identitas.dart'; import 'package:fundex_app/pages/kyc/design.dart'; import 'package:fundex_app/pages/transaction/Transaction.dart'; +import 'package:grouped_checkbox/grouped_checkbox.dart'; class Validasi { static String validate(String val) { - return val.isEmpty ? 'Harus di isi.' : null; + return val.isEmpty ? 'Harus diisi' : null; } } class ValidasiEmail { static String validate(String value) { if (value.isEmpty) { - return 'Email harus di isi'; + return 'Email harus diisi'; } if (!RegExp("^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+.[a-z]").hasMatch(value)) { return 'Email tidak valid'; @@ -49,34 +50,80 @@ class _DataPendukungState extends State { String _emailKantor; // ignore: unused_field String _tujuanInvestasi; - bool valueCheckbox = false; bool _checkBox = false; var _onPressed; + List tujuanInvestasiList = [ + 'Pendapatan', + 'Spekulasi', + 'Investasi', + 'Price Appreciation', + 'Lain-lain', + ]; + List checkedtujuanInvestasiList = []; - final notifikasiCheckbox = [ - CheckboxNotificationSetting(title: 'Gaji'), - CheckboxNotificationSetting(title: 'Hibah'), - CheckboxNotificationSetting( - title: 'Pasangan, Orang Tua, Keluarga atau Teman'), - CheckboxNotificationSetting( - title: 'Santunan (Dana Pensiun, Donatur, Asuransi)'), - CheckboxNotificationSetting(title: 'Hasil Usaha'), - CheckboxNotificationSetting(title: 'Warisan'), - CheckboxNotificationSetting( - title: 'Hasil Investasi (Bunga, Capital Gain, Dividen)'), - CheckboxNotificationSetting(title: 'Undian / Hadiah'), + List sumberPenghasilanList = [ + 'Gaji', + 'Hibah', + 'Pasangan, Orang Tua, Keluarga atau Teman', + 'Santunan (Dana Pensiun, Donatur, Asuransi)', + 'Hasil Usaha', + 'Warisan', + 'Hasil Investasi (Bunga, Capital Gain, Dividen)', + 'Undian / Hadiah', ]; + List checkedSumberPenghasilanList = []; + double opacitySumberPenghasilan = 0; + double opacityTujuanInvestasi = 0; + bool tujuanInvestasi = false; + bool sumberPenghasilan = false; + + void validasiTujuanInvestasi(itemList) { + checkedtujuanInvestasiList = itemList; + print('CHECKED SUMBER PENGHASILAN $itemList'); + if (checkedtujuanInvestasiList.isNotEmpty) { + setState(() { + tujuanInvestasi = true; + opacityTujuanInvestasi = 0; + }); + } else { + setState(() { + tujuanInvestasi = false; + opacityTujuanInvestasi = 1; + }); + } + } + + void validasiSumberPenghasilan(itemList) { + checkedSumberPenghasilanList = itemList; + print('CHECKED SUMBER PENGHASILAN $itemList'); + if (checkedSumberPenghasilanList.isNotEmpty) { + setState(() { + sumberPenghasilan = true; + opacitySumberPenghasilan = 0; + }); + } else { + setState(() { + sumberPenghasilan = false; + opacitySumberPenghasilan = 1; + }); + } + } @override Widget build(BuildContext context) { if (_checkBox == true) { _onPressed = () { if (!_formkey.currentState.validate()) { + validasiSumberPenghasilan(checkedSumberPenghasilanList); + validasiTujuanInvestasi(checkedtujuanInvestasiList); print("Failed"); return; } - print(valueCheckbox); - if (valueCheckbox == false) { + + if (tujuanInvestasi == false || sumberPenghasilan == false) { + validasiSumberPenghasilan(checkedSumberPenghasilanList); + validasiTujuanInvestasi(checkedtujuanInvestasiList); + print('Tujuan Investasi or Sumber Penghasilan masih kosong bro'); return; } Navigator.push(context, MaterialPageRoute(builder: (context) { @@ -216,6 +263,7 @@ class _DataPendukungState extends State { child: Form( key: _formkey, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ // biodata data identitas Container( @@ -261,8 +309,9 @@ class _DataPendukungState extends State { // checkbox sumber penghasilan Container( - child: Column( + child: Flex( mainAxisAlignment: MainAxisAlignment.start, + direction: Axis.vertical, children: [ Container( width: 343, @@ -276,19 +325,35 @@ class _DataPendukungState extends State { Container( margin: EdgeInsets.fromLTRB(0, 4, 0, 0), width: 343, - height: 450, - child: ListView( - key: Key("listViewCheckbox"), - children: [ - ...notifikasiCheckbox - .map(buildSingleCheckbox) - .toList(), - ], + child: GroupedCheckbox( + itemList: sumberPenghasilanList, + checkedItemList: + checkedSumberPenghasilanList, + onChanged: (itemList) { + validasiSumberPenghasilan(itemList); + }, + orientation: + CheckboxOrientation.VERTICAL, + checkColor: white, + activeColor: primary, ), - ) + ), ], ), ), + Container( + margin: EdgeInsets.fromLTRB(10, 0, 0, 0), + child: Opacity( + opacity: opacitySumberPenghasilan, + child: Text( + 'Harus diisi', + style: TextStyle( + color: formError, + fontSize: 12, + ), + ), + ), + ), // form pekerjaan Container( @@ -463,61 +528,92 @@ class _DataPendukungState extends State { // form email kantor Container( - child: Row(children: [ - Column(children: [ - Container( - width: 343, - margin: - const EdgeInsets.fromLTRB(0, 12, 0, 4), - child: Text( - "Email Kantor *", - style: miniTitleTextStyle(), - ), - ), - Container( - width: 343, - margin: EdgeInsets.fromLTRB(0, 4, 0, 0), - child: TextFormField( - key: Key('emailKantor'), - keyboardType: TextInputType.emailAddress, - decoration: formInputDecoration(), - validator: ValidasiEmail.validate, - onSaved: (String emailKantor) { - _emailKantor = emailKantor; - }, + child: Row( + children: [ + Column( + children: [ + Container( + width: 343, + margin: const EdgeInsets.fromLTRB( + 0, 12, 0, 4), + child: Text( + "Email Kantor *", + style: miniTitleTextStyle(), + ), + ), + Container( + width: 343, + margin: + EdgeInsets.fromLTRB(0, 4, 0, 0), + child: TextFormField( + key: Key('emailKantor'), + keyboardType: + TextInputType.emailAddress, + decoration: formInputDecoration(), + validator: ValidasiEmail.validate, + onSaved: (String emailKantor) { + _emailKantor = emailKantor; + }, + ), + ), + ], ), - ), - ]) - ])), + ], + ), + ), // form tujuan investasi Container( - child: Row(children: [ - Column(children: [ - Container( - width: 343, - margin: - const EdgeInsets.fromLTRB(0, 12, 0, 4), - child: Text( - "Tujuan Investasi *", - style: miniTitleTextStyle(), + child: Row( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + width: 343, + margin: const EdgeInsets.fromLTRB( + 0, 12, 0, 4), + child: Text( + "Tujuan Investasi *", + style: miniTitleTextStyle(), + ), + ), + Container( + width: 343, + margin: + EdgeInsets.fromLTRB(0, 4, 0, 0), + child: GroupedCheckbox( + itemList: tujuanInvestasiList, + checkedItemList: + checkedtujuanInvestasiList, + onChanged: (itemList) { + validasiTujuanInvestasi(itemList); + }, + orientation: + CheckboxOrientation.VERTICAL, + checkColor: white, + activeColor: primary, + ), + ), + ], ), - ), - Container( - width: 343, - margin: EdgeInsets.fromLTRB(0, 4, 0, 0), - child: TextFormField( - key: Key('tujuanInvestasi'), - keyboardType: TextInputType.text, - decoration: formInputDecoration(), - validator: Validasi.validate, - onSaved: (String tujuanInvestasi) { - _tujuanInvestasi = tujuanInvestasi; - }, + ], + ), + ), + Container( + margin: EdgeInsets.fromLTRB(10, 0, 0, 0), + child: Opacity( + opacity: opacityTujuanInvestasi, + child: Text( + 'Harus diisi', + style: TextStyle( + color: formError, + fontSize: 12, ), ), - ]) - ])), + ), + ), // container text Container( @@ -676,42 +772,4 @@ class _DataPendukungState extends State { color: primary, ); } - - Widget buildSingleCheckbox(CheckboxNotificationSetting notification) => - grupCheckbox( - notification: notification, - onClicked: () { - setState(() { - final newValue = !notification.value; - notification.value = newValue; - valueCheckbox = newValue; - }); - }, - ); - - Widget grupCheckbox({ - @required CheckboxNotificationSetting notification, - @required VoidCallback onClicked, - }) => - ListTile( - onTap: onClicked, - leading: Checkbox( - value: notification.value, - onChanged: (valueCheckbox) => onClicked(), - ), - title: Text( - notification.title, - style: checkboxTextStyle(), - ), - ); -} - -class CheckboxNotificationSetting { - String title; - bool value; - - CheckboxNotificationSetting({ - @required this.title, - this.value = false, - }); } diff --git a/pubspec.lock b/pubspec.lock index af6467a..3fbf588 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -324,6 +324,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0" + grouped_checkbox: + dependency: "direct main" + description: + name: grouped_checkbox + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" html: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c61fe72..66d9f80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: dotted_border: ^1.0.7 image_picker: any flutter_multi_carousel: ^1.0.0 + grouped_checkbox: ^1.0.0 # The following adds the Cupertino Icons font to your application. -- GitLab