first commit
This commit is contained in:
190
lib/resource/component-bersama/card_kendaraan.dart
Normal file
190
lib/resource/component-bersama/card_kendaraan.dart
Normal file
@@ -0,0 +1,190 @@
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MainCardKendaraan extends StatelessWidget {
|
||||
final KendaraanModel? kendaraanModel;
|
||||
|
||||
MainCardKendaraan(this.kendaraanModel);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Stack(
|
||||
children: [
|
||||
kendaraanModel != null
|
||||
? Image.asset(
|
||||
"assets/images/card.png",
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fill,
|
||||
)
|
||||
: Image.asset(
|
||||
"assets/images/card_empty.png",
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"Data Pribadi Kendaraan Anda",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
children: [
|
||||
kendaraanModel != null
|
||||
? kendaraanModel?.jenisKendaraan != "motor"
|
||||
? Image.asset(
|
||||
"assets/images/car.png",
|
||||
width: 110,
|
||||
height: 110,
|
||||
)
|
||||
: Image.asset(
|
||||
"assets/images/motor.png",
|
||||
width: 110,
|
||||
height: 110,
|
||||
)
|
||||
: Image.asset(
|
||||
"assets/images/img_empty.png",
|
||||
width: 110,
|
||||
height: 110,
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
// width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Tipe Kendaraan : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF25235B),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
kendaraanModel != null
|
||||
? kendaraanModel!.namaKendaraan
|
||||
: "-",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFFffffff),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Nomor Plat :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF25235B),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
kendaraanModel != null
|
||||
? kendaraanModel!.nomorPlat
|
||||
: "-",
|
||||
// "AS 7713 JJA",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFFffffff),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Bahan Bakar saat ini",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF25235B),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 5,
|
||||
// ),
|
||||
Text(
|
||||
kendaraanModel != null
|
||||
? kendaraanModel!.bahanBakar
|
||||
: "-",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFFffffff),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
92
lib/resource/component-bersama/chart.dart
Normal file
92
lib/resource/component-bersama/chart.dart
Normal file
@@ -0,0 +1,92 @@
|
||||
// import 'package:fl_chart_app/presentation/resources/app_resources.dart';
|
||||
// import 'package:fl_chart_app/util/extensions/color_extensions.dart';
|
||||
import 'package:bbm_tracking/model/transaksiPerMonth_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:syncfusion_flutter_charts/sparkcharts.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BarChartSample3 extends StatefulWidget {
|
||||
List<TransaksiPerMonthModel> dataTransaksi;
|
||||
String param;
|
||||
BarChartSample3({required this.dataTransaksi, required this.param, Key? key}): super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => BarChartSample3State();
|
||||
}
|
||||
|
||||
class BarChartSample3State extends State<BarChartSample3> {
|
||||
List<double> dtTotalBayar = [];
|
||||
List<double> dtTotalLiter = [];
|
||||
late List<TransaksiPerMonthModel> dtTransaksi;
|
||||
DateTime today = DateTime.now();
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
dtTransaksi = widget.dataTransaksi;
|
||||
final daysInMonth = DateTime(today.year, today.month + 1, 0).day;
|
||||
|
||||
for (var i = 1; i <= daysInMonth; i++) {
|
||||
if (dtTransaksi.length > 0) {
|
||||
for(int j = 0; j < dtTransaksi.length; j++)
|
||||
{
|
||||
if(i == dtTransaksi[j].tanggalTransaksi.day)
|
||||
{
|
||||
dtTotalBayar.add(dtTransaksi[j].totalBayar.toDouble());
|
||||
dtTotalLiter.add(dtTransaksi[j].totalLiter);
|
||||
break;
|
||||
}else{
|
||||
dtTotalBayar.add(0);
|
||||
dtTotalLiter.add(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dtTotalBayar.add(0);
|
||||
dtTotalLiter.add(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(widget.param);
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.6,
|
||||
child: widget.param == "Harga"
|
||||
? SfSparkLineChart(
|
||||
//Enable the trackball
|
||||
trackball: SparkChartTrackball(
|
||||
activationMode: SparkChartActivationMode.tap,
|
||||
color: Colors.black,
|
||||
),
|
||||
//Enable marker
|
||||
marker: SparkChartMarker(
|
||||
displayMode: SparkChartMarkerDisplayMode.all,
|
||||
color: Colors.black),
|
||||
//Enable data label
|
||||
labelDisplayMode: SparkChartLabelDisplayMode.none,
|
||||
color: Color(0xFFFC8D05),
|
||||
// dashArray: [],
|
||||
data: dtTotalBayar,
|
||||
)
|
||||
: SfSparkLineChart(
|
||||
//Enable the trackball
|
||||
trackball: SparkChartTrackball(
|
||||
activationMode: SparkChartActivationMode.tap,
|
||||
color: Colors.black,
|
||||
),
|
||||
//Enable marker
|
||||
marker: SparkChartMarker(
|
||||
displayMode: SparkChartMarkerDisplayMode.all,
|
||||
color: Colors.black),
|
||||
//Enable data label
|
||||
labelDisplayMode: SparkChartLabelDisplayMode.none,
|
||||
color: Color(0xFFFC8D05),
|
||||
// dashArray: [],
|
||||
data: dtTotalLiter,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user