first commit
This commit is contained in:
191
lib/pages/AboutApps/component/about.dart
Normal file
191
lib/pages/AboutApps/component/about.dart
Normal file
@@ -0,0 +1,191 @@
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class About extends StatefulWidget {
|
||||
const About({super.key});
|
||||
|
||||
@override
|
||||
State<About> createState() => _AboutState();
|
||||
}
|
||||
|
||||
class _AboutState extends State<About> {
|
||||
TextStyle styles = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w200,
|
||||
);
|
||||
TextStyle styles1 = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
);
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
child: SingleChildScrollView(
|
||||
reverse: true,
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 55,
|
||||
),
|
||||
Container(
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 1,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Tentang Aplikasi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17,
|
||||
color: Color(0xff1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 20,
|
||||
bottom: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset(
|
||||
"assets/images/logoMesinPom.png",
|
||||
width: 35,
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"BBM",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Tracking",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
about1,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
about2,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
about3,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
Salam1,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
Salam2,
|
||||
style: styles1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
191
lib/pages/AboutApps/component/kebijakan.dart
Normal file
191
lib/pages/AboutApps/component/kebijakan.dart
Normal file
@@ -0,0 +1,191 @@
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Kebijakan extends StatefulWidget {
|
||||
const Kebijakan({super.key});
|
||||
|
||||
@override
|
||||
State<Kebijakan> createState() => _KebijakanState();
|
||||
}
|
||||
|
||||
class _KebijakanState extends State<Kebijakan> {
|
||||
TextStyle styles = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w200,
|
||||
);
|
||||
TextStyle styles1 = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
);
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
child: SingleChildScrollView(
|
||||
reverse: true,
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 55,
|
||||
),
|
||||
Container(
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 1,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Kebijakan & Privasi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17,
|
||||
color: Color(0xff1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 20,
|
||||
bottom: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset(
|
||||
"assets/images/logoMesinPom.png",
|
||||
width: 35,
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"BBM",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Tracking",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
Kebijakan1,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
Kebijakan2,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
Kebijakan3,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
Salam1,
|
||||
style: styles,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
Salam2,
|
||||
style: styles1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
161
lib/pages/AboutApps/index.dart
Normal file
161
lib/pages/AboutApps/index.dart
Normal file
@@ -0,0 +1,161 @@
|
||||
import 'package:bbm_tracking/pages/AboutApps/component/about.dart';
|
||||
import 'package:bbm_tracking/pages/AboutApps/component/kebijakan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AboutApps extends StatefulWidget {
|
||||
const AboutApps({super.key});
|
||||
|
||||
@override
|
||||
State<AboutApps> createState() => _AboutAppsState();
|
||||
}
|
||||
|
||||
class _AboutAppsState extends State<AboutApps> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Tentang Aplikasi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17,
|
||||
color: Color(0xff1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
card("kebijakan"),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
card("tentang"),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/about_person.png"),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
"Ada Yang Bisa Kami Bantu ?",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget card(tujuan) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
tujuan == "kebijakan"
|
||||
? Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Kebijakan(),
|
||||
),
|
||||
)
|
||||
: Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => About(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
margin: EdgeInsets.all(5),
|
||||
padding: EdgeInsets.only(
|
||||
left: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset(
|
||||
tujuan == "kebijakan"
|
||||
? "assets/images/help-circle.png"
|
||||
: "assets/images/user.png",
|
||||
width: 30,
|
||||
height: 30,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
tujuan == "kebijakan"
|
||||
? "Kebijakan & Privasi"
|
||||
: "Tentang Aplikasi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
color: Color(0xFF455A64),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
tujuan == "kebijakan"
|
||||
? "Baca informasi selengkapnya..."
|
||||
: "Selengkapnya...",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 11,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
273
lib/pages/Performa/index.dart
Normal file
273
lib/pages/Performa/index.dart
Normal file
@@ -0,0 +1,273 @@
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/simulation/index.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Performa extends StatefulWidget {
|
||||
const Performa({super.key});
|
||||
|
||||
@override
|
||||
State<Performa> createState() => _PerformaState();
|
||||
}
|
||||
|
||||
class _PerformaState extends State<Performa> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 54),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Performa Kendaraan",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
// MainCardKendaraan(),
|
||||
InkWell(
|
||||
onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (context) => SimulationScreen())),
|
||||
child: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 13,
|
||||
vertical: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFF1C40F),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Buat Simulasi Kendaraan Anda",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1C7A44),
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xffE3EAEA),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 5.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(9),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 190,
|
||||
// child: BarChartSample3(),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
"Bulan : Januari 2023",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Status Performa Kendaraan Anda minggu ini",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Status Performa",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 8,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemData("Status", "Baik"),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Detail Informasi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 8,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemData("Merek kendaraan", "Honda Beat"),
|
||||
itemData("Jumlah biaya", "Rp. 600.000"),
|
||||
itemData("Jumlah liter bensin", "6 Liter"),
|
||||
itemData("Cubicle Centimeter", "250"),
|
||||
itemData("Jenis Bahan Bakar", "Pertalite"),
|
||||
itemData("Odometer", "304761,25 km"),
|
||||
itemData("Km Tempuh per hari", "8.5 km"),
|
||||
itemData("Total Km Tempuh", "318 km"),
|
||||
itemData("Priode pemakaian", "01 Januari 2023 - 31 Januari 2023")
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemData(key, value) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 6),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 12,
|
||||
),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFD9D9D9),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
key,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 12,
|
||||
),
|
||||
margin: EdgeInsets.symmetric(horizontal: 6),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFBFE5DF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
146
lib/pages/component/custom_dialog_box.dart
Normal file
146
lib/pages/component/custom_dialog_box.dart
Normal file
@@ -0,0 +1,146 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomeDialogBox extends StatefulWidget {
|
||||
String title, description, positiveText, negativeText, screen;
|
||||
final Function onChangeStatus;
|
||||
|
||||
CustomeDialogBox({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.positiveText,
|
||||
required this.negativeText,
|
||||
required this.screen,
|
||||
required this.onChangeStatus,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CustomeDialogBox> createState() => _CustomeDialogBoxState();
|
||||
}
|
||||
|
||||
class _CustomeDialogBoxState extends State<CustomeDialogBox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: contentBox(context),
|
||||
);
|
||||
}
|
||||
|
||||
contentBox(context) {
|
||||
return Container(
|
||||
height: 200,
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
widget.title,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
color: Color(0xFF29170B),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
widget.description,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11,
|
||||
color: Color(0xFF080705),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 35,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 15),
|
||||
child: Text(
|
||||
widget.negativeText,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
color: Color(0xFF29170B),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.onChangeStatus();
|
||||
},
|
||||
child: Container(
|
||||
width: 115,
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Color(0xFF2ECC71),
|
||||
),
|
||||
child: Text(
|
||||
widget.positiveText,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
color: Color(0xFFFFFFFF),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
15
lib/pages/component/dropdown.dart
Normal file
15
lib/pages/component/dropdown.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Dropdown extends StatefulWidget {
|
||||
const Dropdown({super.key});
|
||||
|
||||
@override
|
||||
State<Dropdown> createState() => _DropdownState();
|
||||
}
|
||||
|
||||
class _DropdownState extends State<Dropdown> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
76
lib/pages/component/success_dialog_box.dart
Normal file
76
lib/pages/component/success_dialog_box.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SuccessDialogBox extends StatefulWidget {
|
||||
String deskripsi;
|
||||
SuccessDialogBox({
|
||||
super.key,
|
||||
required this.deskripsi,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SuccessDialogBox> createState() => _SuccessDialogBoxState();
|
||||
}
|
||||
|
||||
class _SuccessDialogBoxState extends State<SuccessDialogBox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Container(
|
||||
height: 160,
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
color: Color(0xFF2ECC71),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset('assets/images/success.png'),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"BERHASIL",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
widget.deskripsi,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 10,
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
119
lib/pages/form-tambah-data-bensin/displayImage.dart
Normal file
119
lib/pages/form-tambah-data-bensin/displayImage.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DisplayImage extends StatefulWidget {
|
||||
final File imagePath;
|
||||
const DisplayImage({super.key, required this.imagePath});
|
||||
|
||||
@override
|
||||
State<DisplayImage> createState() => _DisplayImageState();
|
||||
}
|
||||
|
||||
class _DisplayImageState extends State<DisplayImage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 50,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: BackButton(),
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
color: Colors.amber),
|
||||
child: Image.file(
|
||||
File(widget.imagePath.path),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context, widget.imagePath);
|
||||
},
|
||||
child: Container(
|
||||
height: 33,
|
||||
width: 100,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE74C3C),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
|
||||
child: Container(
|
||||
child: Text(
|
||||
"Hapus",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
color: Colors.white,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget BackButton() {
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pop(context, null),
|
||||
child: Container(
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
1495
lib/pages/form-tambah-data-bensin/index.dart
Normal file
1495
lib/pages/form-tambah-data-bensin/index.dart
Normal file
File diff suppressed because it is too large
Load Diff
259
lib/pages/home.dart
Normal file
259
lib/pages/home.dart
Normal file
@@ -0,0 +1,259 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/pages/AboutApps/index.dart';
|
||||
import 'package:bbm_tracking/pages/form-tambah-data-bensin/index.dart';
|
||||
import 'package:bbm_tracking/pages/kendaraan/form-tambah-kendaraan/form.dart';
|
||||
import 'package:bbm_tracking/pages/kendaraan/index_kendaraan.dart';
|
||||
import 'package:bbm_tracking/repository/kendaraan/kendaraan_repository.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:bbm_tracking/resource/component-bersama/chart.dart';
|
||||
import 'package:bbm_tracking/pages/mainMenu/component/item_bensin.dart';
|
||||
import 'package:bbm_tracking/pages/mainMenu/index.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/index.dart';
|
||||
import 'package:bbm_tracking/resource/popup/popup.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:pandabar/main.view.dart';
|
||||
import 'package:pandabar/model.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
final String screen;
|
||||
final String param;
|
||||
|
||||
Home(this.screen, this.param);
|
||||
|
||||
@override
|
||||
State<Home> createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
late String screen = 'home';
|
||||
late String param;
|
||||
late List<KendaraanModel> dataKendaraan;
|
||||
late KendaraanModel dt;
|
||||
late bool paramKendaran = false;
|
||||
late int paramText = 0;
|
||||
late bool cond = false;
|
||||
var firstCamera;
|
||||
|
||||
late bool _gpsEnable;
|
||||
void ButtonAddTransaksi() {
|
||||
if (dataKendaraan != null || dataKendaraan.length != 0) {
|
||||
for (KendaraanModel element in dataKendaraan) {
|
||||
if (element.status == 1) {
|
||||
paramKendaran = true;
|
||||
dt = element;
|
||||
cond = true;
|
||||
paramText = 2;
|
||||
break;
|
||||
}
|
||||
paramKendaran = false;
|
||||
paramText = 1;
|
||||
}
|
||||
} else {
|
||||
paramKendaran = false;
|
||||
paramText = 0;
|
||||
}
|
||||
|
||||
paramKendaran
|
||||
? Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FormTamabahDataBensin(
|
||||
kendaraanModel: dt,
|
||||
camera: firstCamera,
|
||||
key: UniqueKey(),
|
||||
),
|
||||
),
|
||||
)
|
||||
: showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return PopUp(
|
||||
text: paramText == 1
|
||||
? "Maaf, Silakan aktifkan kendaraan Anda terlebih dahulu"
|
||||
: "Maaf, Silakan tambahkan kendaraan Anda terlebih dahulu",
|
||||
param: "negative",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
screen = widget.screen;
|
||||
param = widget.param;
|
||||
|
||||
context.read<BbmBloc>()..add(BBMStarted());
|
||||
// setState(() {
|
||||
// widget.screen != null ? screen = "${widget.screen}" : screen = "home";
|
||||
// });
|
||||
initilizeCamera();
|
||||
checkGPS();
|
||||
}
|
||||
|
||||
Future<Position> checkGPS() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
// Test if location services are enabled.
|
||||
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
|
||||
if (!serviceEnabled) {
|
||||
// Location services are not enabled don't continue
|
||||
// accessing the position and request users of the
|
||||
// App to enable the location services.
|
||||
return Future.error('Location services are disabled.');
|
||||
} else {
|
||||
_gpsEnable = true;
|
||||
}
|
||||
|
||||
permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
// Permissions are denied, next time you could try
|
||||
// requesting permissions again (this is also where
|
||||
// Android's shouldShowRequestPermissionRationale
|
||||
// returned true. According to Android guidelines
|
||||
// your App should show an explanatory UI now.
|
||||
return Future.error('Location permissions are denied');
|
||||
}
|
||||
}
|
||||
|
||||
if (permission == LocationPermission.deniedForever) {
|
||||
// Permissions are denied forever, handle appropriately.
|
||||
return Future.error(
|
||||
'Location permissions are permanently denied, we cannot request permissions.');
|
||||
}
|
||||
// When we reach here, permissions are granted and we can
|
||||
// continue accessing the position of the device.
|
||||
return await Geolocator.getCurrentPosition();
|
||||
}
|
||||
|
||||
Future<void> initilizeCamera() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Obtain a list of the available cameras on the device.
|
||||
final cameras = await availableCameras();
|
||||
|
||||
// Get a specific camera from the list of available cameras.
|
||||
setState(() {
|
||||
firstCamera = cameras.first;
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: new Text('Apa Kamu Yakin?'),
|
||||
content: new Text('Kamu ingin Keluar Aplikasi'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: new Text('No'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => SystemNavigator.pop(),
|
||||
child: new Text('Yes'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// String page = 'home';
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
bottomNavigationBar: PandaBar(
|
||||
backgroundColor: Color(0xFFD2E1E1),
|
||||
buttonSelectedColor: Color(0xFFFC8D05),
|
||||
fabColors: [Color(0xFFFC8D05), Color(0xFFDDB05E)],
|
||||
buttonData: [
|
||||
PandaBarButtonData(
|
||||
id: 'home',
|
||||
icon: Icons.home,
|
||||
title: 'Home',
|
||||
),
|
||||
PandaBarButtonData(
|
||||
id: 'kendaraan',
|
||||
icon: Icons.directions_car_filled_outlined,
|
||||
title: 'Kendaraan',
|
||||
),
|
||||
PandaBarButtonData(
|
||||
id: 'riwayat',
|
||||
icon: Icons.account_balance_wallet_outlined,
|
||||
title: 'Riwayat',
|
||||
),
|
||||
PandaBarButtonData(
|
||||
id: 'tentang',
|
||||
icon: Icons.assignment_late_outlined,
|
||||
title: 'Tentang',
|
||||
),
|
||||
],
|
||||
onChange: (id) {
|
||||
setState(() {
|
||||
screen = id;
|
||||
});
|
||||
},
|
||||
onFabButtonPressed: () {
|
||||
ButtonAddTransaksi();
|
||||
},
|
||||
),
|
||||
body: BlocBuilder<BbmBloc, BbmState>(
|
||||
builder: (context, state) {
|
||||
if (state is BBMLoaded) {
|
||||
dataKendaraan = state.kendaraan;
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
// print("screen = " + param);
|
||||
switch (screen) {
|
||||
case 'home':
|
||||
return IndexMainMenu();
|
||||
case 'kendaraan':
|
||||
// context.read<BbmBloc>().add(BBMAllDataKendaraan());
|
||||
return IndexKendaraan();
|
||||
case 'riwayat':
|
||||
return Riwayat(
|
||||
dataKendaraan,
|
||||
key: UniqueKey(),
|
||||
data: state.transaksi,
|
||||
);
|
||||
case 'tentang':
|
||||
return AboutApps();
|
||||
default:
|
||||
return IndexMainMenu();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
104
lib/pages/mainMenu/component/item_bensin.dart
Normal file
104
lib/pages/mainMenu/component/item_bensin.dart
Normal file
@@ -0,0 +1,104 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/resource/convert_money/convert_money.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ItemBensin extends StatelessWidget {
|
||||
final BensinModel data;
|
||||
|
||||
const ItemBensin({
|
||||
super.key,
|
||||
required this.data,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 180,
|
||||
height: 75,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Color(0xFF677D81),
|
||||
width: 1.0,
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
data.text,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/images/gas-pump.png",
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
"${CurrencyFormat.convertToIdr(data.harga,0)} /Liter",
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Container(
|
||||
width: double.maxFinite,
|
||||
child: Text(
|
||||
"Update on Juli 24, 2023",
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
542
lib/pages/mainMenu/index.dart
Normal file
542
lib/pages/mainMenu/index.dart
Normal file
@@ -0,0 +1,542 @@
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksiPerMonth_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/repository/kendaraan/kendaraan_repository.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:bbm_tracking/resource/component-bersama/chart.dart';
|
||||
import 'package:bbm_tracking/pages/mainMenu/component/item_bensin.dart';
|
||||
import 'package:bbm_tracking/resource/component-bersama/card_kendaraan.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
// import 'package:month_year_picker/month_year_picker.dart';
|
||||
import 'package:simple_month_year_picker/simple_month_year_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class IndexMainMenu extends StatefulWidget {
|
||||
const IndexMainMenu({super.key});
|
||||
|
||||
@override
|
||||
State<IndexMainMenu> createState() => _IndexMainMenuState();
|
||||
}
|
||||
|
||||
class _IndexMainMenuState extends State<IndexMainMenu> {
|
||||
String _toggle = "Harga";
|
||||
DateTime _selected = DateTime.now();
|
||||
int totalPengeluaran = 0;
|
||||
double totalBBM = 0;
|
||||
late int count;
|
||||
|
||||
late List<TransaksiPerMonthModel> dataTransaksiThisMonth = [];
|
||||
late List<KendaraanModel> dataKendaraan = [];
|
||||
late List<TransaksiModel> dataTransaksi = [];
|
||||
KendaraanModel? dataKendaraanObject;
|
||||
bool isLoading = false;
|
||||
@override
|
||||
void initState() {
|
||||
context.read<BbmBloc>()..add(BBMStarted());
|
||||
initializeDateFormatting();
|
||||
count = 0;
|
||||
loadData(_selected);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> loadData(DateTime date) async {
|
||||
List<KendaraanModel> dtKendaraan =
|
||||
await KendaraanRepository().loadKendaraan();
|
||||
setState(() {
|
||||
dataKendaraan.addAll(dtKendaraan);
|
||||
});
|
||||
|
||||
bool cond = false;
|
||||
int i = 0;
|
||||
|
||||
for (int i = 0; i < dtKendaraan.length; i++) {
|
||||
if (cond == false) {
|
||||
if (dataKendaraan[i].status == 1) {
|
||||
setState(() {
|
||||
dataKendaraanObject = dataKendaraan[i];
|
||||
});
|
||||
cond = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<TransaksiPerMonthModel> dt = await TransaksiRepository()
|
||||
.loadTransaksiThisMonth(
|
||||
DateFormat("yyyy-MM-dd").parse(date.toString()).toString());
|
||||
dataTransaksiThisMonth.clear();
|
||||
dt.forEach((element) {
|
||||
if (element.kendaraanId == dataKendaraanObject?.id.toString()) {
|
||||
setState(() {
|
||||
dataTransaksiThisMonth.add(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
List<TransaksiModel> dtM = await TransaksiRepository().loadTransaksi();
|
||||
dtM.forEach((element) {
|
||||
if (dataKendaraanObject?.status == 1) {
|
||||
totalPengeluaran += element.totalBayar.toInt();
|
||||
totalBBM += double.parse(element.totalLiter);
|
||||
}
|
||||
});
|
||||
dataTransaksi.addAll(dtM);
|
||||
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle styleData = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 6,
|
||||
color: Color(0xFF3B3C48),
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
void selectedDate(DateTime time) {
|
||||
setState(() {
|
||||
_selected = time;
|
||||
loadData(time);
|
||||
});
|
||||
}
|
||||
|
||||
void selectedToggle(String toogle) {
|
||||
setState(() {
|
||||
count++;
|
||||
_toggle = toogle;
|
||||
});
|
||||
}
|
||||
|
||||
// String _month = 0;
|
||||
// int _year = 0;
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
return (await showDialog(
|
||||
context: context,
|
||||
builder: (context) => new AlertDialog(
|
||||
title: new Text('Apa Kamu Yakin?'),
|
||||
content: new Text('Kamu ingin Keluar Aplikasi'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: new Text('No'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: new Text('Yes'),
|
||||
),
|
||||
],
|
||||
),
|
||||
)) ??
|
||||
false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isLoading
|
||||
? Container(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 10),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Hallo,",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 14,
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Selamat datang di Aplikasi BBM-Tracking",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MainCardKendaraan(dataKendaraanObject),
|
||||
SecondWidget(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
ItemListBensin(listBensin),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"Pembaruan,",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 8,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
" 24 Juli 2023",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 8,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
DatePerforma(dataTransaksiThisMonth),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container();
|
||||
}
|
||||
|
||||
Widget DatePerforma(dataTransaksiThisMonth) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 350,
|
||||
margin: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xffE3EAEA),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 5.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(9),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
"Grafik Pengisian Bahan Bakar",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 16,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return MonthPicker(
|
||||
onChangeDate: (bulan, tahun) {
|
||||
setState(() {
|
||||
_selected =
|
||||
DateTime.parse("${tahun}-${bulan}-01");
|
||||
selectedDate(_selected);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: Color(0xffDDB05E),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Text(
|
||||
DateFormat(
|
||||
"MMMM yyyy",
|
||||
"id_ID",
|
||||
).format(_selected),
|
||||
// _selected.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
color: Color(0xFF1A0F0F),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
width: 130,
|
||||
height: 30,
|
||||
alignment: Alignment.topRight,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => selectedToggle("Harga"),
|
||||
child: Container(
|
||||
width: 65,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: _toggle == "Harga"
|
||||
? Color(0xFF677D81)
|
||||
: Color(0xFFffffff),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 7),
|
||||
child: Text(
|
||||
"Harga",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
color: _toggle == "Harga"
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => selectedToggle("Liter"),
|
||||
child: Container(
|
||||
width: 65,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: _toggle == "Harga"
|
||||
? Color(0xFFffffff)
|
||||
: Color(0xFF677D81),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 7),
|
||||
child: Text(
|
||||
"Liter",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
color: _toggle == "Harga"
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 190,
|
||||
child: BarChartSample3(
|
||||
key: UniqueKey(),
|
||||
dataTransaksi: dataTransaksiThisMonth,
|
||||
param: _toggle,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
"Bulan : ${DateFormat('MMMM').format(DateTime(0, _selected.month.toInt()))} ${_selected.year.toString()}",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget SecondWidget() {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: 0,
|
||||
horizontal: 4,
|
||||
),
|
||||
width: double.infinity,
|
||||
height: 58,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF677D81),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: const Offset(
|
||||
0.5,
|
||||
2.0,
|
||||
),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
children: [
|
||||
ItemTotalLiterUang("Total Pengeluaran", "pengeluaran"),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
ItemTotalLiterUang("Total Bahan Bakar", "liter"),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ItemTotalLiterUang(text, param) {
|
||||
return Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 7,
|
||||
top: 3,
|
||||
bottom: 3,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
param == "pengeluaran"
|
||||
? "assets/images/compass.png"
|
||||
: "assets/images/gas-pump.png",
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
param == "pengeluaran"
|
||||
? "${CurrencyFormat.convertToIdr(totalPengeluaran, 0)}"
|
||||
: "${totalBBM.toStringAsFixed(2)} Liter",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ItemListBensin(List<BensinModel> dataModel) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 80,
|
||||
child: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: dataModel.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: ItemBensin(data: dataModel.elementAt(index)),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
248
lib/pages/onBoard/on_board_start.dart
Normal file
248
lib/pages/onBoard/on_board_start.dart
Normal file
@@ -0,0 +1,248 @@
|
||||
import 'package:bbm_tracking/model/status_m.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class OnBoardStart extends StatefulWidget {
|
||||
const OnBoardStart({super.key});
|
||||
|
||||
@override
|
||||
State<OnBoardStart> createState() => _OnBoardStartState();
|
||||
}
|
||||
|
||||
class _OnBoardStartState extends State<OnBoardStart> {
|
||||
bool isFirst = true;
|
||||
bool isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print("object");
|
||||
loadData();
|
||||
}
|
||||
|
||||
Future<void> loadData() async {
|
||||
List<StatusModel> dt = await TransaksiRepository().getStatusIn();
|
||||
if (dt.isNotEmpty) {
|
||||
setState(() {
|
||||
isFirst = false;
|
||||
isLoading = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateFirstIn() async {
|
||||
await TransaksiRepository().insertStatusIn();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isLoading
|
||||
? Container()
|
||||
: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
// mainAxisAlignment: ,
|
||||
children: [
|
||||
Image.asset('assets/images/firstIcon.png'),
|
||||
Text(
|
||||
"BBM",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"Lacak & Pantau bahan bakar",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Kendaraan Anda",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Color(0xFF1A0F0F),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
"Dapat dengan mudah memantau penggunaan bahan bakar atau BBM yang kendaraan Anda gunakan ",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
isFirst
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
updateFirstIn();
|
||||
return showDialogKendaraan(context);
|
||||
},
|
||||
)
|
||||
: Navigator.of(context).pushReplacement(
|
||||
_createRoute(),
|
||||
);
|
||||
// print("object");
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 100,
|
||||
right: 100,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Color(0xFFFC8D05),
|
||||
width: 25.0,
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30),
|
||||
),
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/images/arrow-right.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Dialog showDialogKendaraan(BuildContext context) {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
child: Container(
|
||||
height: 400,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"This app accesses your device's location to record your location while refueling. This location information is used exclusively to provide a better service in recording your refueling history. Your privacy is our priority, and your location data will not be used for any other purpose or shared with third parties without your permission.",
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
'when the app/location is running in the background or when the app is closed, location/system does not retrieve your location data. Location will only be used when you actively want to log detailed gas station locations using coordinates.',
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
'The main features of apps that use device location are:',
|
||||
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
'- Location Logging Feature: The feature that uses location is when you add gas filling data on the gas filling form.',
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
'We value your trust and are committed to maintaining the security and privacy of your data.',
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
"Thank you for using BBM Tracking application",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
"Management System",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 7,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacement(
|
||||
_createRoute(),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
"I Accept",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 14,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Route _createRoute() {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => Home("", ""),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(4.0, 3.0);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.ease;
|
||||
|
||||
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
62
lib/pages/onBoard/splash_screen.dart
Normal file
62
lib/pages/onBoard/splash_screen.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bbm_tracking/pages/onBoard/on_board_start.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SplsScreen extends StatefulWidget {
|
||||
const SplsScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SplsScreen> createState() => _SplsScreen();
|
||||
}
|
||||
|
||||
class _SplsScreen extends State<SplsScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Timer(
|
||||
Duration(seconds: 3),
|
||||
() {
|
||||
Navigator.of(context).pushReplacement(
|
||||
_createRoute(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: Container(
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [Image.asset("assets/images/Logo.png")],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Route _createRoute() {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
const OnBoardStart(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(4.0, 3.0);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.ease;
|
||||
|
||||
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
241
lib/pages/riwayat/component/item-history.dart
Normal file
241
lib/pages/riwayat/component/item-history.dart
Normal file
@@ -0,0 +1,241 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/riwayat-detail/riwayat-detail.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ItemHistory extends StatefulWidget {
|
||||
TransaksiModel data;
|
||||
KendaraanModel kendaraan;
|
||||
ItemHistory({super.key, required this.data, required this.kendaraan});
|
||||
|
||||
@override
|
||||
State<ItemHistory> createState() => _ItemHistoryState();
|
||||
}
|
||||
|
||||
class _ItemHistoryState extends State<ItemHistory> {
|
||||
TransaksiModel? data;
|
||||
List<BensinModel> dataBensin = listBensin;
|
||||
KendaraanModel? kendaraan;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
data = widget.data;
|
||||
kendaraan = widget.kendaraan;
|
||||
}
|
||||
|
||||
String reformatDate(DateTime date) {
|
||||
String data = "";
|
||||
for (int i = 0; i < bulan.length; i++) {
|
||||
if (i + 1 == date.month) {
|
||||
data += "${bulan[i].substring(0, 3)}, ${date.day} ${date.year}";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RiwayatDetail(
|
||||
data: data!,
|
||||
key: UniqueKey(),
|
||||
kendaraan: kendaraan!,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 1, color: Color(0xFF677D81)),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(color: Color(0xFFE1E1E1)),
|
||||
height: 42,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Pengisian",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
dataBensin[int.parse(data!.bensinId) - 1]
|
||||
.text
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 10,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
"Data : ${reformatDate(data!.tanggalTransaksi)}",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 10,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Image.asset(
|
||||
"assets/images/${dataBensin[int.parse(data!.bensinId) - 1].perusahaan.toLowerCase()}.png"),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
padding: EdgeInsets.only(top: 6),
|
||||
width: 50,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: data?.status == 1
|
||||
? Color(0xFF58D68D)
|
||||
: Color(0XFFFC8D05),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
// alignment: Alignment.topRight,
|
||||
child: Text(
|
||||
data?.status == 1 ? "selesai" : "draft",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 35,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Total Harga:",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
CurrencyFormat.convertToIdr(data?.totalBayar, 0),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Lokasi SPBU:",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${data?.lokasiPertamina}",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
413
lib/pages/riwayat/component/makePdf.dart
Normal file
413
lib/pages/riwayat/component/makePdf.dart
Normal file
@@ -0,0 +1,413 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:bbm_tracking/resource/convert_money/convert_money.dart';
|
||||
import 'package:bbm_tracking/resource/data-bensin/data-bensin.dart';
|
||||
import 'package:bbm_tracking/resource/data-tanggal/bulan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:printing/printing.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class MakePdf extends StatelessWidget {
|
||||
TransaksiModel transaksi;
|
||||
KendaraanModel kendaraan;
|
||||
MakePdf({super.key, required this.transaksi, required this.kendaraan});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("PDF Preview"),
|
||||
),
|
||||
body: PdfPreview(
|
||||
build: (context) => makePdf(transaksi, kendaraan),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<PhotoModel> photos = [];
|
||||
List<Uint8List> imagesUint8list = [];
|
||||
List<pw.Widget> pdfImagesWidget = [];
|
||||
|
||||
Future<List<PhotoModel>> loadPhoto(param) async {
|
||||
List<PhotoModel> photo = await TransaksiRepository().getPhoto(param);
|
||||
return photo;
|
||||
}
|
||||
|
||||
String reformatDate(DateTime date) {
|
||||
String data = "";
|
||||
for (int i = 0; i < bulan.length; i++) {
|
||||
if (i + 1 == date.month) {
|
||||
data += "${date.day} ${bulan[i]} ${date.year}";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Future<Uint8List> makePdf(
|
||||
TransaksiModel transaksi,
|
||||
KendaraanModel kendaraan,
|
||||
) async {
|
||||
final pdf = pw.Document();
|
||||
photos = await loadPhoto(transaksi.kodeTransaksi);
|
||||
|
||||
photos.forEach((element) async {
|
||||
var replace = "/storage/emulated/0/Pictures/" +
|
||||
element.namePhoto.replaceAll(RegExp(':'), '_') +
|
||||
".jpg";
|
||||
Uri myUri = Uri.parse(replace);
|
||||
File imageFile = new File.fromUri(myUri);
|
||||
// final ByteData bytes = await imageFile.readAsBytes();
|
||||
final Uint8List byteList = imageFile.readAsBytesSync();
|
||||
|
||||
imagesUint8list.add(byteList);
|
||||
});
|
||||
|
||||
pdfImagesWidget = imagesUint8list.map(
|
||||
(image) {
|
||||
return pw.Padding(
|
||||
padding: pw.EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
child: pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
mainAxisSize: pw.MainAxisSize.max,
|
||||
children: [
|
||||
pw.SizedBox(height: 10),
|
||||
pw.Image(
|
||||
pw.MemoryImage(
|
||||
image,
|
||||
),
|
||||
height: 400,
|
||||
fit: pw.BoxFit.fitHeight),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
|
||||
|
||||
final fontData = await rootBundle.load("assets/fonts/Poppins-Medium.ttf");
|
||||
final ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
||||
pdf.addPage(
|
||||
pw.Page(
|
||||
margin: pw.EdgeInsets.all(10),
|
||||
pageFormat: PdfPageFormat.a4,
|
||||
build: (context) {
|
||||
return pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.start,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Detail Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Kode Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.kodeTransaksi,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Text(
|
||||
"Tipe Kendaraan",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
kendaraan.namaKendaraan,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
kendaraan.nomorPlat,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Text(
|
||||
"Detail",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Padding(
|
||||
padding: pw.EdgeInsets.symmetric(horizontal: 50),
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Center(
|
||||
child: pw.Text(
|
||||
"Tipe Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.Center(
|
||||
child: pw.Text(
|
||||
"Pengisian Bahan Bakar",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Align(
|
||||
alignment: pw.Alignment.topLeft,
|
||||
child: pw.Text(
|
||||
"Data Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.Align(
|
||||
alignment: pw.Alignment.topRight,
|
||||
child: pw.Text(
|
||||
reformatDate(transaksi.tanggalTransaksi),
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Waktu",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.tanggalTransaksi.hour}:${transaksi.tanggalTransaksi.minute} WIB",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Jenis Bahan Bakar",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
listBensin[int.parse(transaksi.bensinId) - 1].text,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Alamat SPBU",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.lokasiPertamina,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Total Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.totalLiter} Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Harga / Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${CurrencyFormat.convertToIdr(listBensin[int.parse(transaksi.bensinId) - 1].harga, 0)}",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Total Pembayaran",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
CurrencyFormat.convertToIdr(transaksi.totalBayar, 0),
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Odometer",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.odometer} KM",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Catatan",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.catatan,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
mainAxisSize: pw.MainAxisSize.max,
|
||||
children: pdfImagesWidget,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
}
|
||||
138
lib/pages/riwayat/component/viewImage.dart
Normal file
138
lib/pages/riwayat/component/viewImage.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class ViewImage extends StatefulWidget {
|
||||
final List<String> imagePath;
|
||||
const ViewImage({super.key, required this.imagePath});
|
||||
|
||||
@override
|
||||
State<ViewImage> createState() => _ViewImageState();
|
||||
}
|
||||
|
||||
class _ViewImageState extends State<ViewImage> {
|
||||
late List<String> dataPhoto;
|
||||
bool loading = false;
|
||||
// List<FileModel> _files = new List<FileModel>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
load();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
dataPhoto = widget.imagePath;
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: loading
|
||||
? Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 50,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: BackButton(),
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
child: Expanded(
|
||||
child: ListView.builder(
|
||||
// shrinkWrap: true,
|
||||
itemCount: dataPhoto.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var replace = "/storage/emulated/0/Pictures/" +
|
||||
dataPhoto[index].replaceAll(RegExp(':'), '_')+".jpg";
|
||||
print("counting ${dataPhoto.length.toString()}, path = ${replace}");
|
||||
return ScreenImage(
|
||||
replace,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ScreenImage(param) {
|
||||
print("counting data ${param}");
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
color: Colors.amber),
|
||||
child: Image.file(
|
||||
File(param),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget BackButton() {
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Container(
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
300
lib/pages/riwayat/index.dart
Normal file
300
lib/pages/riwayat/index.dart
Normal file
@@ -0,0 +1,300 @@
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/component/item-history.dart';
|
||||
import 'package:bbm_tracking/resource/popup/popup.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Riwayat extends StatefulWidget {
|
||||
List<TransaksiModel> data;
|
||||
List<KendaraanModel> kendaraan;
|
||||
Riwayat(this.kendaraan, {super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<Riwayat> createState() => _RiwayatState();
|
||||
}
|
||||
|
||||
class _RiwayatState extends State<Riwayat> {
|
||||
KendaraanModel? kendaraan;
|
||||
// String kendaraan = 'motor';
|
||||
late String _tab = 'selesai';
|
||||
late List<TransaksiModel> data;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
data = widget.data;
|
||||
print("counting ${data.length}");
|
||||
loadDataKendaraan();
|
||||
}
|
||||
|
||||
void loadDataKendaraan() {
|
||||
for (KendaraanModel element in widget.kendaraan) {
|
||||
if (element.status == 1) {
|
||||
kendaraan = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Riwayat Transaksi Pengisian Anda",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17,
|
||||
color: Color(0xff1A0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
height: 75,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
color:
|
||||
kendaraan != null ? Color(0xFFFC8D05) : Color(0xFFAEAEAE),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Image.asset(
|
||||
kendaraan != null
|
||||
? kendaraan?.jenisKendaraan == "motor"
|
||||
? "assets/images/motor.png"
|
||||
: "assets/images/car.png"
|
||||
: "assets/images/img_empty.png",
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
"Tipe Kendaraan : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
kendaraan != null
|
||||
? "${kendaraan?.namaKendaraan} / ${kendaraan?.nomorPlat}"
|
||||
: "- / -",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Container(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: Text(
|
||||
// "Ganti Kendaraan",
|
||||
// style: TextStyle(
|
||||
// fontSize: 11,
|
||||
// color: Color(0xFF1C7A44),
|
||||
// fontFamily: 'Poppins',
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontStyle: FontStyle.italic,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// setState(() {
|
||||
// _tab = 'selesai';
|
||||
// });
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Selesai",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Divider(
|
||||
color: _tab == 'selesai'
|
||||
? Color(0xFF58D68D)
|
||||
: Colors.transparent,
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// setState(() {
|
||||
// _tab = 'draft';
|
||||
// });
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return PopUp(
|
||||
text: "Masih dalam Tahap Pengembangan",
|
||||
param: "negative",
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Draft",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Divider(
|
||||
color: _tab == 'draft'
|
||||
? Color(0xFF58D68D)
|
||||
: Colors.transparent,
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Anda memiliki ${kendaraan != null ? data.length.toString() : 0} data transaksi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF828282),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 7,
|
||||
),
|
||||
kendaraan != null
|
||||
? Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.only(bottom: 400),
|
||||
shrinkWrap: true,
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ItemHistory(
|
||||
data: data.elementAt(index),
|
||||
kendaraan: kendaraan!,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 80,
|
||||
),
|
||||
Image.asset(
|
||||
"assets/images/sad_person.png",
|
||||
width: 70,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Anda masih belum memiliki data",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 13,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
321
lib/pages/riwayat/riwayat-detail/riwayat-detail.dart
Normal file
321
lib/pages/riwayat/riwayat-detail/riwayat-detail.dart
Normal file
@@ -0,0 +1,321 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/component/makePdf.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/component/viewImage.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class RiwayatDetail extends StatefulWidget {
|
||||
TransaksiModel data;
|
||||
KendaraanModel kendaraan;
|
||||
RiwayatDetail({super.key, required this.data, required this.kendaraan});
|
||||
|
||||
@override
|
||||
State<RiwayatDetail> createState() => _RiwayatDetailState();
|
||||
}
|
||||
|
||||
class _RiwayatDetailState extends State<RiwayatDetail> {
|
||||
late TransaksiModel data;
|
||||
late KendaraanModel kendaraan;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
data = widget.data;
|
||||
kendaraan = widget.kendaraan;
|
||||
}
|
||||
|
||||
Future<List<PhotoModel>> loadPhoto(param) async {
|
||||
List<PhotoModel> photo = await TransaksiRepository().getPhoto(param);
|
||||
return photo;
|
||||
}
|
||||
|
||||
_showImage(path) async {
|
||||
List<PhotoModel> photo = await loadPhoto(path);
|
||||
List<String> data = [];
|
||||
photo.forEach((element) {
|
||||
data.add(element.namePhoto);
|
||||
});
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ViewImage(imagePath: data),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String reformatDate(DateTime date) {
|
||||
String data = "";
|
||||
for (int i = 0; i < bulan.length; i++) {
|
||||
if (i + 1 == date.month) {
|
||||
data += "${date.day} ${bulan[i]} ${date.year}";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
TextStyle style = TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
);
|
||||
|
||||
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(
|
||||
margin: EdgeInsets.only(
|
||||
top: 50,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Detail Transaksi",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Transaksi Berhasil",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF25A35A),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Container(
|
||||
child: Text(
|
||||
data.kodeTransaksi,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MakePdf(
|
||||
transaksi: data,
|
||||
kendaraan: kendaraan),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
child: Text(
|
||||
"Download",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF1C7A44),
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 1, color: Color(0xFF677D81)),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Tipe Kendaraan",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemDetail(kendaraan.namaKendaraan, kendaraan.nomorPlat),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 1, color: Color(0xFF677D81)),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Details",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
itemDetail("Tipe transaksi", "Pengisian Bahan Bakar"),
|
||||
itemDetail(
|
||||
"Data Transaksi", reformatDate(data.tanggalTransaksi)),
|
||||
itemDetail("Waktu",
|
||||
"${data.tanggalTransaksi.hour}:${data.tanggalTransaksi.minute} WIB"),
|
||||
itemDetail("Jenis Bahan Bakar",
|
||||
listBensin[int.parse(data.bensinId) - 1].text),
|
||||
itemDetail("Total Liter", "${data.totalLiter} Liter"),
|
||||
itemDetail("Harga/Liter",
|
||||
"${CurrencyFormat.convertToIdr(listBensin[int.parse(data.bensinId) - 1].harga, 0)}"),
|
||||
itemDetail("Total Pembayaran",
|
||||
"${CurrencyFormat.convertToIdr(data.totalBayar, 0)}"),
|
||||
itemDetail("Odometer/km", "${data.odometer} km"),
|
||||
itemDetaill("Gambar", "Lihat Gambar", data.kodeTransaksi),
|
||||
itemDetail("Catatan Tambahan", data.catatan),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemDetaill(item, value, val) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: Text(
|
||||
item,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
_showImage(val);
|
||||
},
|
||||
child: Container(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF25A35A),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemDetail(item, value) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: Text(
|
||||
item,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.right,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
294
lib/pages/simulation/index.dart
Normal file
294
lib/pages/simulation/index.dart
Normal file
@@ -0,0 +1,294 @@
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SimulationScreen extends StatefulWidget {
|
||||
const SimulationScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SimulationScreen> createState() => _SimulationScreenState();
|
||||
}
|
||||
|
||||
class _SimulationScreenState extends State<SimulationScreen> {
|
||||
List<String> tipe_kendaraan = ["Motor", "Mobil"];
|
||||
List<String> merek_kendaraan = ["Beat", "NMax", "PCX", "Ninja"];
|
||||
|
||||
bool toogleTipe = false;
|
||||
bool toogleMerek = false;
|
||||
bool toogleBBM = false;
|
||||
bool tooglePriode = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 52),
|
||||
child: Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Container(
|
||||
width: 70,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Simulasi Pemakaian",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: Color(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Color(0xFF1A0F0F3D),
|
||||
height: 2,
|
||||
thickness: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 6,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
"Simulasi Performa Bahan Bakar Kendaraan",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
FormField("-- Pilih Tipe Kendaraan --", tipe_kendaraan,
|
||||
toogleTipe, "tipe"),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
FormField("-- Pilih Kendaraan --", merek_kendaraan, toogleMerek,
|
||||
"merek"),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
FormField("-- Pilih Jenis Bahan Bakar --", listBensin,
|
||||
toogleBBM, "bbm"),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
FormField("-- Pilih Periode --", null, tooglePriode, "periode"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget FormField(
|
||||
txtTitle,
|
||||
data,
|
||||
toogle,
|
||||
toogleParam,
|
||||
) {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFBFE5DF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
txtTitle,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
toogleParam == "tipe"
|
||||
? toogleTipe = !toogleTipe
|
||||
: toogleParam == "merek"
|
||||
? toogleMerek = !toogleMerek
|
||||
: toogleParam == "bbm"
|
||||
? toogleBBM = !toogleBBM
|
||||
: toogleParam == "peride"
|
||||
? tooglePriode = !tooglePriode
|
||||
: null;
|
||||
});
|
||||
// print(toogleTipe);
|
||||
},
|
||||
child: Container(
|
||||
child: Icon(
|
||||
Icons.arrow_circle_down,
|
||||
color: Color(0xFFAEAEAE),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: Duration(seconds: 1),
|
||||
width: double.infinity,
|
||||
height: toogleParam == "tipe"
|
||||
? toogleTipe == true
|
||||
? (36 * data.length).toDouble()
|
||||
: 0
|
||||
: toogleParam == "merek"
|
||||
? toogleMerek == true
|
||||
? (36 * data.length).toDouble()
|
||||
: 0
|
||||
: toogleParam == "bbm"
|
||||
? toogleBBM == true
|
||||
? (26 * data.length).toDouble()
|
||||
: 0
|
||||
: toogleParam == "periode"
|
||||
? tooglePriode == true
|
||||
? 30
|
||||
: 0
|
||||
: 0,
|
||||
curve: Curves.fastOutSlowIn,
|
||||
child: toogleParam != "periode"
|
||||
? listBuilderWidget(data, toogleParam)
|
||||
: formPeriode(),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget formPeriode() {
|
||||
return Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 22),
|
||||
margin: EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFBFE5DF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.calendar_month_outlined),
|
||||
Text(
|
||||
"Awal",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 10,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 22),
|
||||
margin: EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFBFE5DF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget listBuilderWidget(data, toogleParam) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: data.length,
|
||||
scrollDirection: Axis.vertical,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return toogleParam != "bbm"
|
||||
? itemDropDown(data.elementAt(index))
|
||||
: itemDropDown(listBensin[index].text);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemDropDown(key) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 22),
|
||||
margin: EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFBFE5DF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
key,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
color: Color(0xFF677D81),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user