first commit
This commit is contained in:
282
lib/pages/kendaraan/component/card-kendaraan.dart
Normal file
282
lib/pages/kendaraan/component/card-kendaraan.dart
Normal file
@@ -0,0 +1,282 @@
|
||||
import 'package:bbm_tracking/model/Kendaraan_model.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/pages/component/custom_dialog_box.dart';
|
||||
import 'package:bbm_tracking/repository/kendaraan/kendaraan_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
|
||||
class CardKendaraan extends StatefulWidget {
|
||||
final KendaraanModel kendaraan;
|
||||
final Function onChangeStatus;
|
||||
final Function onDelete;
|
||||
final Function onUpdate;
|
||||
CardKendaraan(
|
||||
{required this.kendaraan, required this.onChangeStatus, required this.onDelete, required this.onUpdate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<CardKendaraan> createState() => _CardKendaraanState();
|
||||
}
|
||||
|
||||
class _CardKendaraanState extends State<CardKendaraan> {
|
||||
late KendaraanModel kendaraan;
|
||||
late Function onChangeStatus;
|
||||
late Function onDelete;
|
||||
late Function onUpdate;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
kendaraan = widget.kendaraan;
|
||||
onChangeStatus = widget.onChangeStatus;
|
||||
onDelete = widget.onDelete;
|
||||
onUpdate = widget.onUpdate;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
changeStatus(id, status) {
|
||||
onChangeStatus(id, status);
|
||||
}
|
||||
|
||||
TextStyle styleText = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
);
|
||||
|
||||
TextStyle cardTitle = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
);
|
||||
|
||||
TextStyle cardData = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFFFFFFFF),
|
||||
);
|
||||
|
||||
void deleteData() async {
|
||||
onDelete(kendaraan.id);
|
||||
}
|
||||
|
||||
void updateData() async {
|
||||
onUpdate(kendaraan);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Slidable(
|
||||
// Specify a key if the Slidable is dismissible.
|
||||
key: const ValueKey(0),
|
||||
|
||||
// The start action pane is the one at the left or the top side.
|
||||
startActionPane: ActionPane(
|
||||
// A motion is a widget used to control how the pane animates.
|
||||
motion: const DrawerMotion(),
|
||||
|
||||
// A pane can dismiss the Slidable.
|
||||
// dismissible: DismissiblePane(onDismissed: () {}),
|
||||
|
||||
// All actions are defined in the children parameter.
|
||||
children: [
|
||||
// A SlidableAction can have an icon and/or a label.
|
||||
SlidableAction(
|
||||
backgroundColor: Color(0xFFFE4A49),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label: 'Delete',
|
||||
onPressed: (context) => deleteData(),
|
||||
),
|
||||
SlidableAction(
|
||||
onPressed: (context) => updateData(),
|
||||
backgroundColor: Color(0xFF21B7CA),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.share,
|
||||
label: 'Update',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 145,
|
||||
margin: EdgeInsets.only(
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: kendaraan.status == 1 ? Color(0xFFFC8D05) : Color(0xFFDDB05E),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text(
|
||||
kendaraan.status == 1
|
||||
? "Kendaraan Anda Saat ini"
|
||||
: "Kendaraan Lainnya",
|
||||
style: styleText,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
// padding: EdgeInsets.all(10),
|
||||
child: Switch(
|
||||
activeColor: Color(0xFFDDB05E),
|
||||
activeTrackColor: Colors.white,
|
||||
inactiveThumbColor: Color(0xFFE3EAEA),
|
||||
inactiveTrackColor: Colors.white,
|
||||
splashRadius: 50,
|
||||
value: kendaraan.status == 0 ? false : true,
|
||||
onChanged: (value) {
|
||||
kendaraan.status == 0
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CustomeDialogBox(
|
||||
title: 'Aktifkan Kendaraan?',
|
||||
description:
|
||||
'Anda dapat melihat semua detail data kendaraan ketika status kendaraan sudah aktif kembali',
|
||||
positiveText: "Ya, Aktifkan",
|
||||
negativeText: "Batalkan",
|
||||
screen: "cardKendaraan",
|
||||
onChangeStatus: () => {
|
||||
changeStatus(kendaraan.id, 1),
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: changeStatus(kendaraan.id, 0);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Tipe Kendaraan : ",
|
||||
style: cardTitle,
|
||||
),
|
||||
Text(
|
||||
"${kendaraan.namaKendaraan}",
|
||||
style: cardData,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Nomor Plat : ",
|
||||
style: cardTitle,
|
||||
),
|
||||
Text(
|
||||
"${kendaraan.nomorPlat}",
|
||||
style: cardData,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Bahan Bakar saat ini ",
|
||||
style: cardTitle,
|
||||
),
|
||||
Text(
|
||||
"${kendaraan.bahanBakar}",
|
||||
style: cardData,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
child: Image.asset(
|
||||
kendaraan.jenisKendaraan == "mobil"
|
||||
? "assets/images/car.png"
|
||||
: "assets/images/motor.png",
|
||||
width: 80,
|
||||
height: 80,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Dialog showDialogError() {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Colors.white,
|
||||
child: Container(
|
||||
height: 230,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset("assets/images/error_kendaraan.png"),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
Text(
|
||||
"Maaf, Anda menonaktifkan kendaraan ini",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
415
lib/pages/kendaraan/form-tambah-kendaraan/form.dart
Normal file
415
lib/pages/kendaraan/form-tambah-kendaraan/form.dart
Normal file
@@ -0,0 +1,415 @@
|
||||
import 'package:animated_custom_dropdown/custom_dropdown.dart';
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/pages/component/success_dialog_box.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/mainMenu/index.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class FormKendaraan extends StatefulWidget {
|
||||
String kendaraan;
|
||||
FormKendaraan({super.key, required this.kendaraan});
|
||||
|
||||
@override
|
||||
State<FormKendaraan> createState() => _FormKendaraanState();
|
||||
}
|
||||
|
||||
class _FormKendaraanState extends State<FormKendaraan> {
|
||||
late String kendaraan;
|
||||
late String selectedValueBensin;
|
||||
late KendaraanModel kendaraanModel;
|
||||
|
||||
bool _submitted = false;
|
||||
|
||||
final tipeKendaraanController = TextEditingController();
|
||||
final dateController = TextEditingController();
|
||||
final kilometerController = TextEditingController();
|
||||
final jenisBBMController = TextEditingController();
|
||||
final kepemilikanController = TextEditingController();
|
||||
final nomorPlatController = TextEditingController();
|
||||
final ccController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
kendaraan = widget.kendaraan;
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
setState(() {
|
||||
_submitted = true;
|
||||
});
|
||||
if (tipeKendaraanController.value.text != "" &&
|
||||
dateController.value.text != "" &&
|
||||
kilometerController.value.text != "" &&
|
||||
jenisBBMController.value.text != "" &&
|
||||
kepemilikanController.value.text != "" &&
|
||||
nomorPlatController.value.text != "" &&
|
||||
ccController.value.text != "") {
|
||||
print("success");
|
||||
kendaraanModel = KendaraanModel(
|
||||
id: 0,
|
||||
jenisKendaraan: kendaraan,
|
||||
namaKendaraan: tipeKendaraanController.value.text,
|
||||
nomorPlat: nomorPlatController.value.text,
|
||||
bahanBakar: jenisBBMController.value.text,
|
||||
cc: int.parse(ccController.value.text),
|
||||
odometer: kilometerController.value.text,
|
||||
kepemilikan: kepemilikanController.value.text,
|
||||
status: 0,
|
||||
);
|
||||
context.read<BbmBloc>().add(BBMDataKendaraanAdded(kendaraanModel));
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => Home("", ""),
|
||||
));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SuccessDialogBox(deskripsi: "Berhasil Menambah Data");
|
||||
},
|
||||
);
|
||||
} else {
|
||||
print("faield");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
tipeKendaraanController.dispose();
|
||||
dateController.dispose();
|
||||
kilometerController.dispose();
|
||||
jenisBBMController.dispose();
|
||||
kepemilikanController.dispose();
|
||||
nomorPlatController.dispose();
|
||||
ccController.dispose();
|
||||
}
|
||||
|
||||
List<String> listNamaBensin = List.from(listBensin.map((e) => e.text));
|
||||
List<String> listKepemilikan = [
|
||||
'Pribadi',
|
||||
'Perusahaan',
|
||||
'Sewa',
|
||||
'Lainnya',
|
||||
];
|
||||
// listBensin.map
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 55,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Data Pribadi Kendaraan Anda",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Card(),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
inputField(
|
||||
"Tipe Kendaraan",
|
||||
"Type Of Brand",
|
||||
"text",
|
||||
tipeKendaraanController,
|
||||
),
|
||||
dropdownField(
|
||||
"Jenis Bahan Bakar",
|
||||
listNamaBensin,
|
||||
jenisBBMController,
|
||||
),
|
||||
dropdownField(
|
||||
"Kepemilikan",
|
||||
listKepemilikan,
|
||||
kepemilikanController,
|
||||
),
|
||||
inputField(
|
||||
"Data Penerimaan Kendaraan",
|
||||
"MM/DD/YYYY",
|
||||
"date",
|
||||
dateController,
|
||||
),
|
||||
inputField(
|
||||
"Kilometers Kendaraan",
|
||||
"0 Km",
|
||||
"number",
|
||||
kilometerController,
|
||||
),
|
||||
inputField(
|
||||
"CC Kendaraan",
|
||||
"CC",
|
||||
"number",
|
||||
ccController,
|
||||
),
|
||||
inputField(
|
||||
"Nomor Plat Kendaraan",
|
||||
"Contoh : XX XXXX XXX",
|
||||
"text",
|
||||
nomorPlatController,
|
||||
),
|
||||
SaveButton(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String? _errorText(TextEditingController controller) {
|
||||
var val = controller.value.text.isEmpty ? "Tidak Boleh Kosong" : null;
|
||||
return val;
|
||||
}
|
||||
|
||||
Widget Card() {
|
||||
return Container(
|
||||
height: 75,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
color: Color(0xFFDDB05E),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Image.asset(
|
||||
kendaraan == "motor"
|
||||
? "assets/images/motor.png"
|
||||
: "assets/images/car.png",
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
kendaraan == "motor" ? "Motor" : "Mobil",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget SaveButton() {
|
||||
return InkWell(
|
||||
onTap: _submit,
|
||||
child: Container(
|
||||
width: 90,
|
||||
height: 35,
|
||||
margin: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF2ECC71),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Save Data",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget dropdownField(title, data, TextEditingController controller) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
title != "Kepemilikan"
|
||||
? CustomDropdown.search(
|
||||
fillColor: Color(0xffE3EAEA),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
errorText: _submitted ? _errorText(controller) : null,
|
||||
items: data,
|
||||
controller: controller,
|
||||
)
|
||||
: CustomDropdown(
|
||||
fillColor: Color(0xffE3EAEA),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
items: data,
|
||||
controller: controller,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget inputField(title, hint, typeField, TextEditingController controller) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
textCapitalization: title == "Nomor Plat Kendaraan"
|
||||
? TextCapitalization.characters
|
||||
: title == "Kendaraan"
|
||||
? TextCapitalization.characters
|
||||
: TextCapitalization.none,
|
||||
maxLength: title == "Nomor Plat Kendaraan" ? 11 : 100,
|
||||
controller: controller,
|
||||
readOnly: typeField == "date" && true,
|
||||
keyboardType: typeField != "date" && typeField != "text"
|
||||
? TextInputType.number
|
||||
: TextInputType.text,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(12),
|
||||
),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
// border: BoxDecoration(border:),
|
||||
contentPadding: EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xFFAEAEAE),
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
errorText: _submitted ? _errorText(controller) : null,
|
||||
),
|
||||
onTap: () async {
|
||||
if (typeField == "date") {
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2024),
|
||||
);
|
||||
if (pickedDate != null) {
|
||||
String formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
|
||||
setState(
|
||||
() {
|
||||
controller.text =
|
||||
formattedDate; //set foratted date to TextField value.
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
420
lib/pages/kendaraan/form-update-kendaraan/form-update.dart
Normal file
420
lib/pages/kendaraan/form-update-kendaraan/form-update.dart
Normal file
@@ -0,0 +1,420 @@
|
||||
import 'package:animated_custom_dropdown/custom_dropdown.dart';
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/pages/component/success_dialog_box.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/mainMenu/index.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class FormUpdateKendaraan extends StatefulWidget {
|
||||
KendaraanModel kendaraan;
|
||||
FormUpdateKendaraan({super.key, required this.kendaraan});
|
||||
|
||||
@override
|
||||
State<FormUpdateKendaraan> createState() => _FormUpdateKendaraanState();
|
||||
}
|
||||
|
||||
class _FormUpdateKendaraanState extends State<FormUpdateKendaraan> {
|
||||
late KendaraanModel kendaraan;
|
||||
late String selectedValueBensin;
|
||||
late KendaraanModel kendaraanModel;
|
||||
|
||||
bool _submitted = false;
|
||||
|
||||
final tipeKendaraanController = TextEditingController();
|
||||
final dateController = TextEditingController();
|
||||
final kilometerController = TextEditingController();
|
||||
final jenisBBMController = TextEditingController();
|
||||
final kepemilikanController = TextEditingController();
|
||||
final nomorPlatController = TextEditingController();
|
||||
final ccController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
kendaraan = widget.kendaraan;
|
||||
tipeKendaraanController.text = kendaraan.namaKendaraan;
|
||||
kilometerController.text = kendaraan.odometer;
|
||||
jenisBBMController.text = kendaraan.bahanBakar;
|
||||
kepemilikanController.text = kendaraan.kepemilikan;
|
||||
nomorPlatController.text = kendaraan.nomorPlat;
|
||||
ccController.text = kendaraan.cc.toString();
|
||||
print(kendaraan.jenisKendaraan);
|
||||
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
setState(() {
|
||||
_submitted = true;
|
||||
});
|
||||
if (tipeKendaraanController.value.text != "" &&
|
||||
dateController.value.text != "" &&
|
||||
kilometerController.value.text != "" &&
|
||||
jenisBBMController.value.text != "" &&
|
||||
kepemilikanController.value.text != "" &&
|
||||
nomorPlatController.value.text != "" &&
|
||||
ccController.value.text != "") {
|
||||
kendaraanModel = KendaraanModel(
|
||||
id: kendaraan.id,
|
||||
jenisKendaraan: kendaraan.jenisKendaraan,
|
||||
namaKendaraan: tipeKendaraanController.value.text,
|
||||
nomorPlat: nomorPlatController.value.text,
|
||||
bahanBakar: jenisBBMController.value.text,
|
||||
cc: int.parse(ccController.value.text),
|
||||
odometer: kilometerController.value.text,
|
||||
kepemilikan: kepemilikanController.value.text,
|
||||
status: kendaraan.status,
|
||||
);
|
||||
context.read<BbmBloc>().add(BBMDataKendaraanUpdated(kendaraanModel));
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => Home("", ""),
|
||||
));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SuccessDialogBox(deskripsi: "Berhasil Mengubah Data");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
tipeKendaraanController.dispose();
|
||||
dateController.dispose();
|
||||
kilometerController.dispose();
|
||||
jenisBBMController.dispose();
|
||||
kepemilikanController.dispose();
|
||||
nomorPlatController.dispose();
|
||||
ccController.dispose();
|
||||
}
|
||||
|
||||
List<String> listNamaBensin = List.from(listBensin.map((e) => e.text));
|
||||
List<String> listKepemilikan = [
|
||||
'Pribadi',
|
||||
'Perusahaan',
|
||||
'Sewa',
|
||||
'Lainnya',
|
||||
];
|
||||
// listBensin.map
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 55,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Data Pribadi Kendaraan Anda",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Card(),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
inputField(
|
||||
"Tipe Kendaraan",
|
||||
"Type Of Brand",
|
||||
"text",
|
||||
tipeKendaraanController,
|
||||
),
|
||||
dropdownField(
|
||||
"Jenis Bahan Bakar",
|
||||
listNamaBensin,
|
||||
jenisBBMController,
|
||||
),
|
||||
dropdownField(
|
||||
"Kepemilikan",
|
||||
listKepemilikan,
|
||||
kepemilikanController,
|
||||
),
|
||||
inputField(
|
||||
"Data Penerimaan Kendaraan",
|
||||
"MM/DD/YYYY",
|
||||
"date",
|
||||
dateController,
|
||||
),
|
||||
inputField(
|
||||
"Kilometers Kendaraan",
|
||||
"0 Km",
|
||||
"number",
|
||||
kilometerController,
|
||||
),
|
||||
inputField(
|
||||
"CC Kendaraan",
|
||||
"CC",
|
||||
"number",
|
||||
ccController,
|
||||
),
|
||||
inputField(
|
||||
"Nomor Plat Kendaraan",
|
||||
"Contoh : XX XXXX XXX",
|
||||
"text",
|
||||
nomorPlatController,
|
||||
),
|
||||
SaveButton(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String? _errorText(TextEditingController controller) {
|
||||
var val = controller.value.text.isEmpty ? "Tidak Boleh Kosong" : null;
|
||||
return val;
|
||||
}
|
||||
|
||||
Widget Card() {
|
||||
return Container(
|
||||
height: 75,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
color: Color(0xFFDDB05E),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Image.asset(
|
||||
kendaraan.jenisKendaraan == "motor"
|
||||
? "assets/images/motor.png"
|
||||
: "assets/images/car.png",
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
kendaraan.jenisKendaraan == "motor" ? "Motor" : "Mobil",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget SaveButton() {
|
||||
return InkWell(
|
||||
onTap: _submit,
|
||||
child: Container(
|
||||
width: 90,
|
||||
height: 35,
|
||||
margin: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF2ECC71),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Save Data",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget dropdownField(title, data, TextEditingController controller) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
title != "Kepemilikan"
|
||||
? CustomDropdown.search(
|
||||
fillColor: Color(0xffE3EAEA),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
errorText: _submitted ? _errorText(controller) : null,
|
||||
items: data,
|
||||
controller: controller,
|
||||
)
|
||||
: CustomDropdown(
|
||||
fillColor: Color(0xffE3EAEA),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
items: data,
|
||||
controller: controller,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget inputField(title, hint, typeField, TextEditingController controller) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
textCapitalization: title == "Nomor Plat Kendaraan"
|
||||
? TextCapitalization.characters
|
||||
: title == "Kendaraan"
|
||||
? TextCapitalization.characters
|
||||
: TextCapitalization.none,
|
||||
maxLength: title == "Nomor Plat Kendaraan" ? 11 : 100,
|
||||
controller: controller,
|
||||
readOnly: typeField == "date" && true,
|
||||
keyboardType: typeField != "date" && typeField != "text"
|
||||
? TextInputType.number
|
||||
: TextInputType.text,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(12),
|
||||
),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
// border: BoxDecoration(border:),
|
||||
contentPadding: EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xFFAEAEAE),
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
errorText: _submitted ? _errorText(controller) : null,
|
||||
),
|
||||
onTap: () async {
|
||||
if (typeField == "date") {
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2024),
|
||||
);
|
||||
if (pickedDate != null) {
|
||||
String formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
|
||||
setState(
|
||||
() {
|
||||
controller.text =
|
||||
formattedDate; //set foratted date to TextField value.
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
385
lib/pages/kendaraan/index_kendaraan.dart
Normal file
385
lib/pages/kendaraan/index_kendaraan.dart
Normal file
@@ -0,0 +1,385 @@
|
||||
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/model/Kendaraan_model.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/pages/Performa/index.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/kendaraan/component/card-kendaraan.dart';
|
||||
import 'package:bbm_tracking/pages/kendaraan/form-tambah-kendaraan/form.dart';
|
||||
import 'package:bbm_tracking/pages/kendaraan/form-update-kendaraan/form-update.dart';
|
||||
import 'package:bbm_tracking/repository/kendaraan/kendaraan_repository.dart';
|
||||
import 'package:bbm_tracking/resource/popup/popup.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class IndexKendaraan extends StatefulWidget {
|
||||
const IndexKendaraan({super.key});
|
||||
|
||||
@override
|
||||
State<IndexKendaraan> createState() => _IndexKendaraanState();
|
||||
}
|
||||
|
||||
class _IndexKendaraanState extends State<IndexKendaraan> {
|
||||
List<KendaraanModel> dataKendaraan = [];
|
||||
int counter = 0;
|
||||
|
||||
void changeStatuKendaraan(int id, int status) {
|
||||
context.read<BbmBloc>().add(BBMChangeStatusKendaraan(id, status));
|
||||
dataKendaraan.forEach((element) {
|
||||
element.status = 0;
|
||||
});
|
||||
dataKendaraan
|
||||
.elementAt(dataKendaraan.indexWhere((element) => element.id == id))
|
||||
.status = status;
|
||||
setState(() {
|
||||
counter++;
|
||||
});
|
||||
}
|
||||
|
||||
void deleteDataKendaraan(int id) async {
|
||||
await KendaraanRepository().deleteDataKendaraan(id);
|
||||
dataKendaraan.removeWhere((element) => element.id == id);
|
||||
setState(() {
|
||||
counter++;
|
||||
});
|
||||
}
|
||||
|
||||
void updateKendaraan(KendaraanModel data) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FormUpdateKendaraan(
|
||||
kendaraan: data,
|
||||
key: UniqueKey(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void checkKendaraan(List<KendaraanModel> data) {
|
||||
bool cond = false;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i].status == 1) {
|
||||
cond = true;
|
||||
}
|
||||
}
|
||||
if (cond == true) {
|
||||
// Navigator.of(context)
|
||||
// .push(MaterialPageRoute(builder: (context) => Performa()));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return PopUp(
|
||||
text: "Masih dalam Tahap Pengembangan",
|
||||
param: "negative",
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return PopUp(
|
||||
text: data.isEmpty
|
||||
? "Maaf, belum ada kendaraan yang Anda tambahkan"
|
||||
: "Silahkan Aktifkan Salah Satu Kendaraan Anda",
|
||||
param: "negative",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return showDialogKendaraan();
|
||||
},
|
||||
);
|
||||
},
|
||||
backgroundColor: Color(0xFF677D81),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: BlocBuilder<BbmBloc, BbmState>(
|
||||
builder: (context, state) {
|
||||
if (state is BbmInitial) {
|
||||
return Container(
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
if (state is BBMError) {
|
||||
return Container(
|
||||
child: Center(child: Text(state.message.toString())),
|
||||
);
|
||||
}
|
||||
if (state is BBMLoaded) {
|
||||
dataKendaraan = state.kendaraan;
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(),
|
||||
Container(
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
checkKendaraan(state.kendaraan),
|
||||
child: Text(
|
||||
"Performa Kendaraan",
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff25A35A),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Data Pribadi Kendaraan Anda",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
child: ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: dataKendaraan.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
return CardKendaraan(
|
||||
kendaraan: dataKendaraan.elementAt(index),
|
||||
onChangeStatus: (int id, int status) {
|
||||
changeStatuKendaraan(id, status);
|
||||
},
|
||||
onDelete: (int id) {
|
||||
deleteDataKendaraan(id);
|
||||
},
|
||||
onUpdate: (KendaraanModel kendaraan) {
|
||||
updateKendaraan(kendaraan);
|
||||
},
|
||||
key: UniqueKey(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget ListDataKendaraan() {
|
||||
// return Container(
|
||||
// child: ListView.builder(
|
||||
// scrollDirection: Axis.vertical,
|
||||
// itemCount: _dataKendaraan.length,
|
||||
// shrinkWrap: true,
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// return CardKendaraan(
|
||||
// kendaraan: _dataKendaraan[index],
|
||||
// onChangeStatus: (int id, bool status) {
|
||||
// changeStatuKendaraan(id, status);
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget backButton() {
|
||||
return Container(
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Home("home", ""),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Dialog showNotif(txt) {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
child: Container(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/images/sad_person.png",
|
||||
width: 70,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
txt,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 13,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Dialog showDialogKendaraan() {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
child: Container(
|
||||
height: 230,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Pilih Kendaraan",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 18,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FormKendaraan(kendaraan: "motor"),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: chooseKendaraan(
|
||||
"assets/images/motor.png",
|
||||
"Motor",
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 7,
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFFECDEDE),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 7,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FormKendaraan(kendaraan: "mobil"),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: chooseKendaraan("assets/images/car.png", "Mobil"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container chooseKendaraan(image, text) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
image,
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 15,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user