first commit
This commit is contained in:
33
lib/app.dart
Normal file
33
lib/app.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:bbm_tracking/bloc/bbm_bloc.dart';
|
||||
import 'package:bbm_tracking/pages/onBoard/on_board_start.dart';
|
||||
import 'package:bbm_tracking/pages/onBoard/splash_screen.dart';
|
||||
import 'package:bbm_tracking/repository/kendaraan/kendaraan_repository.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarColor: Color(0xffE3EAEA),
|
||||
),
|
||||
);
|
||||
return BlocProvider(
|
||||
create: (context) => BbmBloc(
|
||||
kendaraanRepository: KendaraanRepository(),
|
||||
transaksiRepository: TransaksiRepository(),
|
||||
)..add(
|
||||
BBMStarted(),
|
||||
),
|
||||
child: MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: const SplsScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
239
lib/bloc/bbm_bloc.dart
Normal file
239
lib/bloc/bbm_bloc.dart
Normal file
@@ -0,0 +1,239 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/photo_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/data-bensin/data-bensin.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
part 'bbm_event.dart';
|
||||
part 'bbm_state.dart';
|
||||
|
||||
class BbmBloc extends Bloc<BbmEvent, BbmState> {
|
||||
final KendaraanRepository kendaraanRepository;
|
||||
final TransaksiRepository transaksiRepository;
|
||||
|
||||
BbmBloc(
|
||||
{required this.kendaraanRepository, required this.transaksiRepository})
|
||||
: super(BbmInitial()) {
|
||||
on<BBMStarted>(_onBBMStarted);
|
||||
on<BBMDataKendaraanAdded>(_onBBMKendaraanAdded);
|
||||
on<BBMDataKendaraanUpdated>(_onBBMKendaraanUpdated);
|
||||
on<BBMChangeStatusKendaraan>(_onBBMChangeStatusKendaraan);
|
||||
on<BBMDataKendaraan>(_onBBMGetDataKendaraan);
|
||||
on<BBMInsertTransaksion>(_onBBMInsertTransaksi);
|
||||
on<BBMAllDataKendaraan>(_onBBMGetAllKendaraan);
|
||||
on<BBMChangeDataTransaction>(_onBBMChangeDataTransaction);
|
||||
}
|
||||
|
||||
Future<void> _onBBMChangeDataTransaction(
|
||||
BBMChangeDataTransaction event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
try {
|
||||
List<KendaraanModel> dataKendaraan =
|
||||
await kendaraanRepository.loadKendaraan();
|
||||
List<TransaksiModel> dataTransaksi =
|
||||
await transaksiRepository.loadTransaksi();
|
||||
List<TransaksiPerMonthModel> dataTransaksiThisMonth =
|
||||
await transaksiRepository.loadTransaksiThisMonth(event.selectedDate);
|
||||
|
||||
emit(BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksiThisMonth));
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMGetDataKendaraan(
|
||||
BBMDataKendaraan event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
final state = this.state;
|
||||
try {
|
||||
if (state is BBMLoaded) {
|
||||
late KendaraanModel dataKendaraan;
|
||||
state.kendaraan.forEach((element) {
|
||||
if (element.id == event.kendaraanModel.id) {
|
||||
dataKendaraan = element;
|
||||
}
|
||||
});
|
||||
emit(BBMSingleData(kendaraan: dataKendaraan));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMGetAllKendaraan(
|
||||
BBMAllDataKendaraan event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
try {
|
||||
List<KendaraanModel> dataKendaraan =
|
||||
await kendaraanRepository.loadKendaraan();
|
||||
emit(BBMKendaraanLoaded(kendaraan: dataKendaraan));
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMChangeStatusKendaraan(
|
||||
BBMChangeStatusKendaraan event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
final state = this.state;
|
||||
try {
|
||||
if (state is BBMLoaded) {
|
||||
await kendaraanRepository.changeStatuKendaraan(event.id, event.status);
|
||||
state.kendaraan.forEach((element) {
|
||||
element.status = 0;
|
||||
});
|
||||
state.kendaraan
|
||||
.elementAt(
|
||||
state.kendaraan.indexWhere((element) => element.id == event.id))
|
||||
.status = event.status;
|
||||
// List<KendaraanModel> dataKendaraan = state.kendaraan;
|
||||
// List<TransaksiModel> dataTransaksi = state.transaksi;
|
||||
// print("data dari bloc = "+dataKendaraan[0].status.toString());
|
||||
// emit(BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksi));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMKendaraanAdded(
|
||||
BBMDataKendaraanAdded event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
final state = this.state;
|
||||
try {
|
||||
if (state is BBMLoaded) {
|
||||
await kendaraanRepository.addedKendaraan(event.kendaraanModel);
|
||||
List<KendaraanModel> dataKendaraan = state.kendaraan;
|
||||
event.kendaraanModel.id = state.kendaraan.length + 1;
|
||||
dataKendaraan.add(event.kendaraanModel);
|
||||
List<TransaksiModel> dataTransaksi = state.transaksi;
|
||||
List<TransaksiPerMonthModel> dataTransaksiThisMonth =
|
||||
await transaksiRepository.loadTransaksiThisMonth(
|
||||
DateFormat("yyyy-MM-dd")
|
||||
.parse(DateTime.now().toString())
|
||||
.toString());
|
||||
emit(
|
||||
BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksiThisMonth),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMKendaraanUpdated(
|
||||
BBMDataKendaraanUpdated event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
final state = this.state;
|
||||
try {
|
||||
if (state is BBMLoaded) {
|
||||
await kendaraanRepository.updateDataKendaraan(event.kendaraanModel);
|
||||
List<KendaraanModel> dataKendaraan = state.kendaraan;
|
||||
// event.kendaraanModel.id = state.kendaraan.length + 1;
|
||||
// dataKendaraan.add(event.kendaraanModel);
|
||||
// dataKendaraan.removeWhere((element) => element.id == event.kendaraanModel.id);
|
||||
dataKendaraan[dataKendaraan.indexWhere((element) => element.id == event.kendaraanModel.id)] = event.kendaraanModel;
|
||||
List<TransaksiModel> dataTransaksi = state.transaksi;
|
||||
List<TransaksiPerMonthModel> dataTransaksiThisMonth =
|
||||
await transaksiRepository.loadTransaksiThisMonth(
|
||||
DateFormat("yyyy-MM-dd")
|
||||
.parse(DateTime.now().toString())
|
||||
.toString());
|
||||
emit(
|
||||
BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksiThisMonth),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMStarted(
|
||||
BBMStarted event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
try {
|
||||
List<KendaraanModel> dataKendaraan =
|
||||
await kendaraanRepository.loadKendaraan();
|
||||
List<TransaksiModel> dataTransaksi =
|
||||
await transaksiRepository.loadTransaksi();
|
||||
List<TransaksiPerMonthModel> dataTransaksiThisMonth =
|
||||
await transaksiRepository.loadTransaksiThisMonth(
|
||||
DateFormat("yyyy-MM-dd")
|
||||
.parse(DateTime.now().toString())
|
||||
.toString());
|
||||
|
||||
emit(BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksiThisMonth));
|
||||
} catch (e) {
|
||||
print("hit here = " + e.toString());
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBBMInsertTransaksi(
|
||||
BBMInsertTransaksion event,
|
||||
Emitter<BbmState> emit,
|
||||
) async {
|
||||
try {
|
||||
final state = this.state;
|
||||
|
||||
if (state is BBMLoaded) {
|
||||
await transaksiRepository.insertTransaksi(event.transaksi);
|
||||
for (PhotoModel element in event.photo) {
|
||||
await transaksiRepository.insertPhoto(element);
|
||||
}
|
||||
|
||||
List<KendaraanModel> dataKendaraan =
|
||||
await kendaraanRepository.loadKendaraan();
|
||||
List<TransaksiModel> dataTransaksi = state.transaksi;
|
||||
event.transaksi.id = dataTransaksi.length + 1;
|
||||
dataTransaksi.add(event.transaksi);
|
||||
// await transaksiRepository.loadTransaksi();
|
||||
List<TransaksiPerMonthModel> dataTransaksiThisMonth =
|
||||
state.transaksiThisMonth;
|
||||
// await transaksiRepository.loadTransaksiThisMonth(
|
||||
// DateFormat("yyyy-MM-dd")
|
||||
// .parse(DateTime.now().toString())
|
||||
// .toString());
|
||||
// state.transaksiThisMonth;
|
||||
var data = event.transaksi;
|
||||
TransaksiPerMonthModel dtIni = new TransaksiPerMonthModel(
|
||||
totalLiter: double.parse(data.totalLiter),
|
||||
totalBayar: data.totalBayar,
|
||||
kendaraanId: data.kendaraanId,
|
||||
tanggalTransaksi: data.tanggalTransaksi,
|
||||
);
|
||||
if (data.tanggalTransaksi.month == DateTime.now().month) {
|
||||
int i = 0;
|
||||
dataTransaksiThisMonth.forEach((element) {
|
||||
if (element.tanggalTransaksi.day == dtIni.tanggalTransaksi.day) {
|
||||
element.totalBayar += dtIni.totalBayar;
|
||||
element.totalLiter += dtIni.totalLiter;
|
||||
state.transaksiThisMonth[i].totalBayar += element.totalBayar;
|
||||
state.transaksiThisMonth[i].totalLiter += element.totalLiter;
|
||||
} else {
|
||||
dataTransaksiThisMonth.add(dtIni);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emit(BBMLoaded(dataKendaraan, dataTransaksi, dataTransaksiThisMonth));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(BBMError(message: "Something Error, ${e}, We Will Fix it"));
|
||||
}
|
||||
}
|
||||
}
|
||||
63
lib/bloc/bbm_event.dart
Normal file
63
lib/bloc/bbm_event.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
part of 'bbm_bloc.dart';
|
||||
|
||||
abstract class BbmEvent extends Equatable {
|
||||
const BbmEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class BBMStarted extends BbmEvent{}
|
||||
|
||||
class BBMDataKendaraanAdded extends BbmEvent{
|
||||
const BBMDataKendaraanAdded(this.kendaraanModel);
|
||||
final KendaraanModel kendaraanModel;
|
||||
|
||||
@override
|
||||
List<Object> get props => [kendaraanModel];
|
||||
}
|
||||
|
||||
class BBMDataKendaraanUpdated extends BbmEvent{
|
||||
const BBMDataKendaraanUpdated(this.kendaraanModel);
|
||||
final KendaraanModel kendaraanModel;
|
||||
|
||||
@override
|
||||
List<Object> get props => [kendaraanModel];
|
||||
}
|
||||
|
||||
class BBMDataKendaraan extends BbmEvent{
|
||||
final KendaraanModel kendaraanModel;
|
||||
const BBMDataKendaraan({required this.kendaraanModel});
|
||||
|
||||
@override
|
||||
List<Object> get props => [kendaraanModel];
|
||||
}
|
||||
|
||||
class BBMAllDataKendaraan extends BbmEvent{}
|
||||
|
||||
class BBMChangeStatusKendaraan extends BbmEvent{
|
||||
final int id;
|
||||
final int status;
|
||||
const BBMChangeStatusKendaraan(this.id, this.status);
|
||||
|
||||
@override
|
||||
List<Object> get props => [id, status];
|
||||
}
|
||||
|
||||
class BBMInsertTransaksion extends BbmEvent{
|
||||
final TransaksiModel transaksi;
|
||||
final List<PhotoModel> photo;
|
||||
const BBMInsertTransaksion({required this.transaksi, required this.photo});
|
||||
|
||||
@override
|
||||
List<Object> get props => [transaksi];
|
||||
}
|
||||
|
||||
class BBMChangeDataTransaction extends BbmEvent{
|
||||
final String selectedDate;
|
||||
|
||||
const BBMChangeDataTransaction({required this.selectedDate});
|
||||
|
||||
@override
|
||||
List<Object> get props => [selectedDate];
|
||||
}
|
||||
44
lib/bloc/bbm_state.dart
Normal file
44
lib/bloc/bbm_state.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
part of 'bbm_bloc.dart';
|
||||
|
||||
abstract class BbmState extends Equatable {
|
||||
const BbmState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class BbmInitial extends BbmState {}
|
||||
|
||||
class BBMSingleData extends BbmState{
|
||||
final KendaraanModel kendaraan;
|
||||
BBMSingleData({required this.kendaraan});
|
||||
}
|
||||
|
||||
class BBMLoaded extends BbmState{
|
||||
final List<KendaraanModel> kendaraan;
|
||||
final List<TransaksiModel> transaksi;
|
||||
final List<TransaksiPerMonthModel> transaksiThisMonth;
|
||||
late List<BensinModel> bensin = listBensin;
|
||||
|
||||
BBMLoaded(this.kendaraan, this.transaksi, this.transaksiThisMonth);
|
||||
}
|
||||
|
||||
class BBMChangeStatus extends BbmState{
|
||||
final List<KendaraanModel> kendaraan;
|
||||
final List<TransaksiModel> transaksi;
|
||||
late List<BensinModel> bensin = listBensin;
|
||||
|
||||
BBMChangeStatus({required this.kendaraan, required this.transaksi});
|
||||
}
|
||||
|
||||
class BBMKendaraanLoaded extends BbmState{
|
||||
final List<KendaraanModel> kendaraan;
|
||||
|
||||
BBMKendaraanLoaded({required this.kendaraan});
|
||||
}
|
||||
|
||||
|
||||
class BBMError extends BbmState{
|
||||
final String message;
|
||||
BBMError({required this.message});
|
||||
}
|
||||
9
lib/main.dart
Normal file
9
lib/main.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'package:bbm_tracking/app.dart';
|
||||
import 'package:bbm_tracking/simple_bloc_observer.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
Bloc.observer = const SimpleBlocObserver();
|
||||
runApp(const App());
|
||||
}
|
||||
17
lib/model/Kendaraan_model.dart
Normal file
17
lib/model/Kendaraan_model.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class Kendaraan {
|
||||
int id;
|
||||
String jenisKendaraan;
|
||||
String namaKendaraan;
|
||||
String nomorPlat;
|
||||
String bahanBakar;
|
||||
bool status;
|
||||
|
||||
Kendaraan({
|
||||
required this.id,
|
||||
required this.jenisKendaraan,
|
||||
required this.namaKendaraan,
|
||||
required this.nomorPlat,
|
||||
required this.bahanBakar,
|
||||
required this.status,
|
||||
});
|
||||
}
|
||||
72
lib/model/MapKendaraanPhoto_m.dart
Normal file
72
lib/model/MapKendaraanPhoto_m.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
|
||||
class TransaksiModel {
|
||||
int id;
|
||||
String kendaraanId;
|
||||
String bensinId;
|
||||
String kodeTransaksi;
|
||||
DateTime tanggalTransaksi;
|
||||
String lokasiPertamina;
|
||||
String totalLiter;
|
||||
int hargaPerLiter;
|
||||
int totalBayar;
|
||||
String odometer;
|
||||
String catatan;
|
||||
String lat;
|
||||
String lang;
|
||||
int status;
|
||||
List<PhotoModel> dataPhoto;
|
||||
|
||||
TransaksiModel({
|
||||
required this.id,
|
||||
required this.kendaraanId,
|
||||
required this.bensinId,
|
||||
required this.kodeTransaksi,
|
||||
required this.tanggalTransaksi,
|
||||
required this.lokasiPertamina,
|
||||
required this.totalLiter,
|
||||
required this.hargaPerLiter,
|
||||
required this.totalBayar,
|
||||
required this.odometer,
|
||||
required this.catatan,
|
||||
required this.lat,
|
||||
required this.lang,
|
||||
required this.status,
|
||||
required this.dataPhoto,
|
||||
});
|
||||
|
||||
TransaksiModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
kendaraanId = json['kendaraanId'],
|
||||
bensinId = json['bensinId'],
|
||||
kodeTransaksi = json['kodeTransaksi'],
|
||||
tanggalTransaksi = json['tanggalTransaksi'],
|
||||
lokasiPertamina = json['lokasiPertamina'],
|
||||
totalLiter = json['totalLiter'],
|
||||
hargaPerLiter = json['hargaPerLiter'],
|
||||
totalBayar = json['totalBayar'],
|
||||
odometer = json['odometer'],
|
||||
catatan = json['catatan'],
|
||||
lat = json['lat'],
|
||||
lang = json['lang'],
|
||||
status = json['status'],
|
||||
dataPhoto = json['dataPhoto'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'kendaraanId': kendaraanId,
|
||||
'bensinId': bensinId,
|
||||
'kodeTransaksi': kodeTransaksi,
|
||||
'tanggalTransaksi': tanggalTransaksi,
|
||||
'lokasiPertamina': lokasiPertamina,
|
||||
'totalLiter': totalLiter,
|
||||
'hargaPerLiter': hargaPerLiter,
|
||||
'totalBayar': totalBayar,
|
||||
'odometer': odometer,
|
||||
'catatan': catatan,
|
||||
'lat': lat,
|
||||
'lang': lang,
|
||||
'status': status,
|
||||
'dataPhoto': dataPhoto,
|
||||
};
|
||||
}
|
||||
32
lib/model/bensin_m.dart
Normal file
32
lib/model/bensin_m.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BensinModel {
|
||||
int id;
|
||||
String value;
|
||||
String text;
|
||||
String perusahaan;
|
||||
int harga;
|
||||
|
||||
BensinModel({
|
||||
required this.id,
|
||||
required this.value,
|
||||
required this.text,
|
||||
required this.perusahaan,
|
||||
required this.harga,
|
||||
});
|
||||
|
||||
BensinModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
value = json['value'],
|
||||
text = json['text'],
|
||||
perusahaan = json['perusahaan'],
|
||||
harga = json['harga'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'value': value,
|
||||
'text': text,
|
||||
'perusahaan': perusahaan,
|
||||
'harga': harga
|
||||
};
|
||||
}
|
||||
46
lib/model/kendaraan_m.dart
Normal file
46
lib/model/kendaraan_m.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
class KendaraanModel {
|
||||
int id;
|
||||
String bahanBakar;
|
||||
String jenisKendaraan;
|
||||
String namaKendaraan;
|
||||
String nomorPlat;
|
||||
int cc;
|
||||
String odometer;
|
||||
String kepemilikan;
|
||||
int status;
|
||||
|
||||
KendaraanModel({
|
||||
required this.id,
|
||||
required this.jenisKendaraan,
|
||||
required this.namaKendaraan,
|
||||
required this.nomorPlat,
|
||||
required this.bahanBakar,
|
||||
required this.cc,
|
||||
required this.odometer,
|
||||
required this.kepemilikan,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
KendaraanModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
jenisKendaraan = json['jenisKendaraan'],
|
||||
namaKendaraan = json['namaKendaraan'],
|
||||
nomorPlat = json['nomorPlat'],
|
||||
bahanBakar = json['bahanBakar'],
|
||||
cc = json['cc'],
|
||||
odometer = json['odometer'],
|
||||
kepemilikan = json['kepemilikan'],
|
||||
status = json['status'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'jenisKendaraan': jenisKendaraan,
|
||||
'namaKendaraan': namaKendaraan,
|
||||
'nomorPlat': nomorPlat,
|
||||
'bahanBakar': bahanBakar,
|
||||
'cc': cc,
|
||||
'odometer': odometer,
|
||||
'kepemilikan': kepemilikan,
|
||||
'status': status
|
||||
};
|
||||
}
|
||||
25
lib/model/photo_m.dart
Normal file
25
lib/model/photo_m.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
class PhotoModel {
|
||||
int id;
|
||||
String transaksi_id;
|
||||
String linkPhoto;
|
||||
String namePhoto;
|
||||
|
||||
PhotoModel(
|
||||
{required this.id,
|
||||
required this.transaksi_id,
|
||||
required this.linkPhoto,
|
||||
required this.namePhoto});
|
||||
|
||||
PhotoModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
transaksi_id = json['transaksi_id'],
|
||||
linkPhoto = json['linkPhoto'],
|
||||
namePhoto = json['namePhoto'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'transaksi_id': transaksi_id,
|
||||
'linkPhoto': linkPhoto,
|
||||
'namePhoto': namePhoto
|
||||
};
|
||||
}
|
||||
17
lib/model/status_m.dart
Normal file
17
lib/model/status_m.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class StatusModel {
|
||||
int id;
|
||||
int status;
|
||||
|
||||
StatusModel(
|
||||
{required this.id,
|
||||
required this.status});
|
||||
|
||||
StatusModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
status = json['status'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'status': status
|
||||
};
|
||||
}
|
||||
27
lib/model/transaksiPerMonth_m.dart
Normal file
27
lib/model/transaksiPerMonth_m.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
class TransaksiPerMonthModel{
|
||||
double totalLiter;
|
||||
int totalBayar;
|
||||
String kendaraanId;
|
||||
DateTime tanggalTransaksi;
|
||||
|
||||
TransaksiPerMonthModel({
|
||||
required this.totalLiter,
|
||||
required this.totalBayar,
|
||||
required this.kendaraanId,
|
||||
required this.tanggalTransaksi
|
||||
});
|
||||
|
||||
TransaksiPerMonthModel.fromJson(Map<String, dynamic> json)
|
||||
: totalBayar = json['totalBayar'],
|
||||
totalLiter = json['totalLiter'],
|
||||
kendaraanId = json['kendaraanId'],
|
||||
tanggalTransaksi = json['tanggalTransaksi'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'totalBayar' : totalBayar,
|
||||
'totalLiter' : totalLiter,
|
||||
'kendaraanId' : kendaraanId,
|
||||
'tanggalTransaksi' : tanggalTransaksi
|
||||
};
|
||||
|
||||
}
|
||||
70
lib/model/transaksi_m.dart
Normal file
70
lib/model/transaksi_m.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
class TransaksiModel {
|
||||
int id;
|
||||
String kendaraanId;
|
||||
String bensinId;
|
||||
String kodeTransaksi;
|
||||
DateTime tanggalTransaksi;
|
||||
DateTime waktuTransaksi;
|
||||
String lokasiPertamina;
|
||||
String totalLiter;
|
||||
int hargaPerLiter;
|
||||
int totalBayar;
|
||||
String odometer;
|
||||
String catatan;
|
||||
String lat;
|
||||
String lang;
|
||||
int status;
|
||||
|
||||
TransaksiModel({
|
||||
required this.id,
|
||||
required this.kendaraanId,
|
||||
required this.bensinId,
|
||||
required this.kodeTransaksi,
|
||||
required this.tanggalTransaksi,
|
||||
required this.waktuTransaksi,
|
||||
required this.lokasiPertamina,
|
||||
required this.totalLiter,
|
||||
required this.hargaPerLiter,
|
||||
required this.totalBayar,
|
||||
required this.odometer,
|
||||
required this.catatan,
|
||||
required this.lat,
|
||||
required this.lang,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
TransaksiModel.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
kendaraanId = json['kendaraanId'],
|
||||
bensinId = json['bensinId'],
|
||||
kodeTransaksi = json['kodeTransaksi'],
|
||||
tanggalTransaksi = json['tanggalTransaksi'],
|
||||
waktuTransaksi = json['waktuTransaksi'],
|
||||
lokasiPertamina = json['lokasiPertamina'],
|
||||
totalLiter = json['totalLiter'],
|
||||
hargaPerLiter = json['hargaPerLiter'],
|
||||
totalBayar = json['totalBayar'],
|
||||
odometer = json['odometer'],
|
||||
catatan = json['catatan'],
|
||||
lat = json['lat'],
|
||||
lang = json['lang'],
|
||||
status = json['status'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'kendaraanId': kendaraanId,
|
||||
'bensinId': bensinId,
|
||||
'kodeTransaksi': kodeTransaksi,
|
||||
'tanggalTransaksi': tanggalTransaksi,
|
||||
'waktuTransaksi': waktuTransaksi,
|
||||
'lokasiPertamina': lokasiPertamina,
|
||||
'totalLiter': totalLiter,
|
||||
'hargaPerLiter': hargaPerLiter,
|
||||
'totalBayar': totalBayar,
|
||||
'odometer': odometer,
|
||||
'catatan': catatan,
|
||||
'lat': lat,
|
||||
'lang': lang,
|
||||
'status': status,
|
||||
};
|
||||
}
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
36
lib/repository/kendaraan/kendaraan_repository.dart
Normal file
36
lib/repository/kendaraan/kendaraan_repository.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/services/databases.dart';
|
||||
|
||||
// const _delay = Duration(milliseconds: 800);
|
||||
|
||||
class KendaraanRepository{
|
||||
|
||||
DatabasesMain service = DatabasesMain();
|
||||
|
||||
Future<List<KendaraanModel>> loadKendaraan() {
|
||||
return service.getAllKendaraan();
|
||||
}
|
||||
|
||||
Future<void> addedKendaraan(KendaraanModel kendaraan)
|
||||
{
|
||||
return service.insertDataKendaraan(kendaraan);
|
||||
}
|
||||
|
||||
Future<void> changeStatuKendaraan(int id, int status)
|
||||
{
|
||||
return service.updateStatusAktifKendaraan(id, status);
|
||||
}
|
||||
|
||||
Future<void> deleteDataKendaraan(int id) async
|
||||
{
|
||||
await service.deleteDataKendaraan(id);
|
||||
}
|
||||
|
||||
Future<void> updateDataKendaraan(KendaraanModel data) async
|
||||
{
|
||||
await service.updateDataKendaraan(data);
|
||||
}
|
||||
|
||||
}
|
||||
45
lib/repository/transaksi/transaksi_repository.dart
Normal file
45
lib/repository/transaksi/transaksi_repository.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
import 'package:bbm_tracking/model/status_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksiPerMonth_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/services/databases.dart';
|
||||
|
||||
class TransaksiRepository
|
||||
{
|
||||
DatabasesMain service = DatabasesMain();
|
||||
Future<List<TransaksiModel>> loadTransaksi()
|
||||
{
|
||||
return service.getAllTransaksiStatusSuccessfull();
|
||||
}
|
||||
|
||||
Future<List<TransaksiPerMonthModel>> loadTransaksiThisMonth(String datetime)
|
||||
{
|
||||
return service.getAllTransaksiStatusSuccessfullThisMonth(datetime);
|
||||
}
|
||||
|
||||
Future<void> insertTransaksi(TransaksiModel model) async
|
||||
{
|
||||
await service.insertDataTransaksi(model);
|
||||
}
|
||||
|
||||
//photo
|
||||
Future<void> insertPhoto(PhotoModel model) async
|
||||
{
|
||||
await service.insertDataPhoto(model);
|
||||
}
|
||||
|
||||
Future<List<PhotoModel>> getPhoto(String param) async{
|
||||
return service.getAllPhoto(param);
|
||||
}
|
||||
|
||||
//status
|
||||
Future<void> insertStatusIn() async
|
||||
{
|
||||
await service.insertDataStatus();
|
||||
}
|
||||
|
||||
Future<List<StatusModel>> getStatusIn() async{
|
||||
return service.getStatusIn();
|
||||
}
|
||||
|
||||
}
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
11
lib/resource/convert_money/convert_money.dart
Normal file
11
lib/resource/convert_money/convert_money.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:intl/intl.dart';
|
||||
class CurrencyFormat {
|
||||
static String convertToIdr(dynamic number, int decimalDigit) {
|
||||
NumberFormat currencyFormatter = NumberFormat.currency(
|
||||
locale: 'id',
|
||||
symbol: 'Rp. ',
|
||||
decimalDigits: decimalDigit,
|
||||
);
|
||||
return currencyFormatter.format(number);
|
||||
}
|
||||
}
|
||||
103
lib/resource/data-bensin/data-bensin.dart
Normal file
103
lib/resource/data-bensin/data-bensin.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
List<BensinModel> listBensin = [
|
||||
BensinModel(
|
||||
id: 1,
|
||||
value: "pertalite",
|
||||
text: "Pertalite",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 10000,
|
||||
),
|
||||
BensinModel(
|
||||
id: 2,
|
||||
value: "pertamax",
|
||||
text: "Pertamax",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 12400,
|
||||
),
|
||||
BensinModel(
|
||||
id: 3,
|
||||
value: "pertamax_turbo",
|
||||
text: "Pertamax Turbo",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 14000,
|
||||
),
|
||||
BensinModel(
|
||||
id: 4,
|
||||
value: "pertamina_dex",
|
||||
text: "Pertamina Dex",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 13550,
|
||||
),
|
||||
BensinModel(
|
||||
id: 5,
|
||||
value: "dexlite",
|
||||
text: "Dexlite",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 13150,
|
||||
),
|
||||
BensinModel(
|
||||
id: 6,
|
||||
value: "solar",
|
||||
text: "Solar",
|
||||
perusahaan: "Pertamina",
|
||||
harga: 6800,
|
||||
),
|
||||
BensinModel(
|
||||
id: 7,
|
||||
value: "shell_v_power_nitro",
|
||||
text: "Shell V-Power Nitro+",
|
||||
perusahaan: "Shell",
|
||||
harga: 14120,
|
||||
),
|
||||
BensinModel(
|
||||
id: 8,
|
||||
value: "shell_v_power",
|
||||
text: "Shell V-Power",
|
||||
perusahaan: "Shell",
|
||||
harga: 13780,
|
||||
),
|
||||
BensinModel(
|
||||
id: 9,
|
||||
value: "shell_super",
|
||||
text: "Shell Super",
|
||||
perusahaan: "Shell",
|
||||
harga: 12920,
|
||||
),
|
||||
BensinModel(
|
||||
id: 10,
|
||||
value: "shell_v_power_diesel",
|
||||
text: "Shell V-Power Diesel",
|
||||
perusahaan: "Shell",
|
||||
harga: 13590,
|
||||
),
|
||||
BensinModel(
|
||||
id: 11,
|
||||
value: "shell_diesel_extra",
|
||||
text: "Shell Diesel Extra",
|
||||
perusahaan: "Shell",
|
||||
harga: 13160,
|
||||
),
|
||||
BensinModel(
|
||||
id: 12,
|
||||
value: "revvo_90",
|
||||
text: "Revvo 90",
|
||||
perusahaan: "Revvo",
|
||||
harga: 11200,
|
||||
),
|
||||
BensinModel(
|
||||
id: 13,
|
||||
value: "revvo_92",
|
||||
text: "Revvo 92",
|
||||
perusahaan: "Revvo",
|
||||
harga: 12400,
|
||||
),
|
||||
BensinModel(
|
||||
id: 14,
|
||||
value: "revvo_95",
|
||||
text: "Revvo 95",
|
||||
perusahaan: "Revvo",
|
||||
harga: 13200,
|
||||
),
|
||||
];
|
||||
1
lib/resource/data-tanggal/bulan.dart
Normal file
1
lib/resource/data-tanggal/bulan.dart
Normal file
@@ -0,0 +1 @@
|
||||
List<String> bulan = ["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"];
|
||||
1
lib/resource/data-tanggal/tahun.dart
Normal file
1
lib/resource/data-tanggal/tahun.dart
Normal file
@@ -0,0 +1 @@
|
||||
List<String> tahun = ["2023","2024","2025","2026","2027","2028","2029","2030"];
|
||||
180
lib/resource/dialog-pickdate/month-pickcer.dart
Normal file
180
lib/resource/dialog-pickdate/month-pickcer.dart
Normal file
@@ -0,0 +1,180 @@
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MonthPicker extends StatefulWidget {
|
||||
// final Function onChangeNextMonth;
|
||||
final Function onChangeDate;
|
||||
// final String bulan;
|
||||
|
||||
const MonthPicker({
|
||||
super.key,
|
||||
required this.onChangeDate,
|
||||
// required this.onChangBeforeMonth,
|
||||
// required this.bulan
|
||||
});
|
||||
|
||||
@override
|
||||
State<MonthPicker> createState() => _MonthPickerState();
|
||||
}
|
||||
|
||||
class _MonthPickerState extends State<MonthPicker> {
|
||||
late Function onChangeDate;
|
||||
|
||||
int _month = 0;
|
||||
int _year = 2023;
|
||||
String mon = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
onChangeDate = widget.onChangeDate;
|
||||
}
|
||||
|
||||
void nextMonth() {
|
||||
setState(() {
|
||||
_month == 11 ? _month = 0 : _month = _month + 1;
|
||||
});
|
||||
// print(bulan.elementAt(_month));
|
||||
}
|
||||
|
||||
void beforeMonth() {
|
||||
setState(() {
|
||||
_month == 0 ? _month = 11 : _month = _month - 1;
|
||||
});
|
||||
// print(bulan.elementAt(_month));
|
||||
}
|
||||
|
||||
void nextYear() {
|
||||
setState(() {
|
||||
_year = _year + 1;
|
||||
});
|
||||
// print(bulan.elementAt(_month));
|
||||
}
|
||||
|
||||
void beforeYear() {
|
||||
setState(() {
|
||||
_year > 2023 ? _year = _year - 1 : null;
|
||||
});
|
||||
// print(bulan.elementAt(_month));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
child: Container(
|
||||
height: 250,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Pilih Tanggal",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 18,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => nextMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
bulan.elementAt(_month),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => beforeMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => nextYear(),
|
||||
child: Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_year.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => beforeYear(),
|
||||
child: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (_month < 10) {
|
||||
mon = "0" + (_month + 1).toString();
|
||||
}
|
||||
onChangeDate(mon.toString(), _year.toString());
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 17,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(9)),
|
||||
color: Color(0xFF2ECC71),
|
||||
),
|
||||
child: Text(
|
||||
"Selesai",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/resource/popup/popup.dart
Normal file
49
lib/resource/popup/popup.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PopUp extends StatefulWidget {
|
||||
String text, param;
|
||||
PopUp({super.key, required this.text, required this.param});
|
||||
|
||||
@override
|
||||
State<PopUp> createState() => _PopUpState();
|
||||
}
|
||||
|
||||
class _PopUpState extends State<PopUp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
elevation: 1,
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
child: Container(
|
||||
height: 200,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
widget.param == "negative" ? "assets/images/sad_person.png" : "assets/images/about_person.png",
|
||||
width: 70,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
widget.text,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF677D81),
|
||||
fontSize: 13,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
9
lib/resource/resource.dart
Normal file
9
lib/resource/resource.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
export 'data-bensin/data-bensin.dart';
|
||||
export 'text/text-kebijakan.dart';
|
||||
export 'component-bersama/card_kendaraan.dart';
|
||||
export 'component-bersama/chart.dart';
|
||||
export 'data-tanggal/bulan.dart';
|
||||
export 'data-tanggal/tahun.dart';
|
||||
export 'dialog-pickdate/month-pickcer.dart';
|
||||
|
||||
export 'convert_money/convert_money.dart';
|
||||
11
lib/resource/text/text-kebijakan.dart
Normal file
11
lib/resource/text/text-kebijakan.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
String Kebijakan1 = "BBM-Tracking menghormati segala sesuatu yang berhubungan dengan privasi Anda. Kami menyusun kebijakan privasi ini untuk membantu Anda memahami data apa pun yang diperoleh, dikumpulkan, diproses, dianalisis, digunakan, dikirim, ditampilkan, diumumkan, diperluas, dihapus, dikirim, dan dimusnahkan pada data pribadi Anda yang disediakan di Aplikasi ini.";
|
||||
String Kebijakan2 = "Data yang disebutkan di atas diatur sesuai dengan kebijakan privasi di aplikasi ini dan disesuaikan kembali dengan peraturan perundang-undangan yang berlaku.";
|
||||
String Kebijakan3 = "Kami berharap Anda benar-benar membaca dan memahami kebijakan privasi ini dengan seksama sehingga Anda mengertikan bagaimana kami mengelola dan melindungi data yang Anda simpan. Dengan menggunakan BBM-Tracking, Anda mengakui bahwa Anda telah membaca dan memahami semua ketentuan yang terdapat dalam kebijakan dan privasi aplikasi ini.";
|
||||
|
||||
String about1 = "Dengan BBM-Tracking App Anda dapat menyimpan riwayat bahan bakar kendaraan yang sedang Anda gunakan. Aplikasi ini membantu Anda memantau setiap kebutuhan kendaraan secara akurat dan tentunya lebih efisien.";
|
||||
String about2 = "Aplikasi BBM-Tracking mencatat semua bahan bakar yang digunakan, biaya dan pelacak jarak tempuh kendaraan yang digunakan. Konsumsi bahan bakar dapat diprediksi sehingga penghematan biaya kendaraan Anda akan jauh lebih baik.";
|
||||
String about3 = "Ayo download aplikasi BBM-Tracking sekarang juga dan nikmati kemudahan tracking BBM kendaraan Anda.";
|
||||
|
||||
|
||||
String Salam1 = "Salam Hormat,";
|
||||
String Salam2 = "Management System";
|
||||
318
lib/services/databases.dart
Normal file
318
lib/services/databases.dart
Normal file
@@ -0,0 +1,318 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
import 'package:bbm_tracking/model/status_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksiPerMonth_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path/path.dart';
|
||||
// import 'package:sqflite/sqflite.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:sqflite/sqflite.dart' as sql;
|
||||
import 'package:sqflite/sqlite_api.dart';
|
||||
|
||||
class DatabasesMain {
|
||||
Future<void> createTablesBensin(sql.Database database) async {
|
||||
await database.execute("""CREATE TABLE bensin(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
value TEXT,
|
||||
text TEXT,
|
||||
perusahaan TEXT,
|
||||
harga INTEGER
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
Future<void> createTablesTransaksi(sql.Database database) async {
|
||||
await database.execute("""CREATE TABLE transaksi(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
kendaraanId TEXT,
|
||||
bensinId TEXT,
|
||||
kodeTransaksi TEXT,
|
||||
tanggalTransaksi DATETIME,
|
||||
waktuTransaksi DATETIME,
|
||||
lokasiPertamina TEXT,
|
||||
totalLiter TEXT,
|
||||
hargaPerLiter INTEGER,
|
||||
totalBayar INTEGER,
|
||||
odometer TEXT,
|
||||
catatan TEXT,
|
||||
latitude TEXT,
|
||||
longitude TEXT,
|
||||
status INTEGER
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
Future<void> createTablesKendaraan(sql.Database database) async {
|
||||
await database.execute("""CREATE TABLE kendaraan(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
bahanBakar TEXT,
|
||||
jenisKendaraan TEXT,
|
||||
namaKendaraan TEXT,
|
||||
nomorPlat TEXT,
|
||||
cc INTEGER,
|
||||
odometer TEXT,
|
||||
kepemilikan TEXT,
|
||||
status INTEGER
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
Future<void> createTablesFirstIn(sql.Database database) async {
|
||||
await database.execute("""CREATE TABLE firstIn(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
status INTEGER
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
Future<void> createTableMapPhotoTransaction(sql.Database database) async {
|
||||
await database.execute("""CREATE TABLE photo(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
transaksi_id TEXT,
|
||||
linkPhoto TEXT,
|
||||
namePhoto TEXT
|
||||
)""");
|
||||
}
|
||||
|
||||
Future<sql.Database> dbs() async {
|
||||
return sql.openDatabase(
|
||||
join(await sql.getDatabasesPath(), 'bbmtracking1.db'),
|
||||
version: 1,
|
||||
onCreate: (sql.Database database, int version) async {
|
||||
await createTablesBensin(database);
|
||||
await createTablesTransaksi(database);
|
||||
await createTablesKendaraan(database);
|
||||
await createTablesFirstIn(database);
|
||||
await createTableMapPhotoTransaction(database);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//kendaraan
|
||||
Future<List<StatusModel>> getStatusIn() async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.query('firstIn');
|
||||
return List.generate(maps.length, (index) {
|
||||
return StatusModel(
|
||||
id: maps[index]['id'],
|
||||
status: maps[index]['status'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> insertDataStatus() async {
|
||||
final db = await dbs();
|
||||
await db.rawInsert("INSERT INTO firstIn(status) VALUES(1)");
|
||||
}
|
||||
|
||||
//bensin
|
||||
Future<List<BensinModel>> getAllBensin() async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.query('bensin');
|
||||
return List.generate(maps.length, (index) {
|
||||
return BensinModel(
|
||||
id: maps[index]['id'],
|
||||
value: maps[index]['value'],
|
||||
text: maps[index]['text'],
|
||||
perusahaan: maps[index]['perusahaan'],
|
||||
harga: maps[index]['harga'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//kendaraan
|
||||
Future<List<KendaraanModel>> getAllKendaraan() async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.query('kendaraan');
|
||||
return List.generate(maps.length, (index) {
|
||||
return KendaraanModel(
|
||||
id: maps[index]['id'],
|
||||
jenisKendaraan: maps[index]['jenisKendaraan'],
|
||||
namaKendaraan: maps[index]['namaKendaraan'],
|
||||
nomorPlat: maps[index]['nomorPlat'],
|
||||
bahanBakar: maps[index]['bahanBakar'],
|
||||
cc: maps[index]['cc'],
|
||||
odometer: maps[index]['odometer'],
|
||||
kepemilikan: maps[index]['kepemilikan'],
|
||||
status: maps[index]['status'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> insertDataKendaraan(KendaraanModel kendaraan) async {
|
||||
final db = await dbs();
|
||||
await db.rawInsert(
|
||||
"INSERT INTO kendaraan(bahanBakar,jenisKendaraan,namaKendaraan,nomorPlat,cc,odometer,kepemilikan,status) VALUES('${kendaraan.bahanBakar}','${kendaraan.jenisKendaraan}','${kendaraan.namaKendaraan}','${kendaraan.nomorPlat}','${kendaraan.cc}','${kendaraan.odometer}','${kendaraan.kepemilikan}','${kendaraan.status}')");
|
||||
}
|
||||
|
||||
Future<void> updateDataKendaraan(KendaraanModel kendaraan) async {
|
||||
final db = await dbs();
|
||||
db.rawUpdate(
|
||||
"UPDATE kendaraan SET bahanBakar=?, jenisKendaraan = ?, namaKendaraan = ?, nomorPlat = ?, cc = ?, odometer = ?, kepemilikan = ? WHERE id = ?",
|
||||
[
|
||||
kendaraan.bahanBakar,
|
||||
kendaraan.jenisKendaraan,
|
||||
kendaraan.namaKendaraan,
|
||||
kendaraan.nomorPlat,
|
||||
kendaraan.cc,
|
||||
kendaraan.odometer,
|
||||
kendaraan.kepemilikan,
|
||||
kendaraan.id,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteDataKendaraan(int id) async {
|
||||
final db = await dbs();
|
||||
await db.rawDelete("DELETE FROM kendaraan WHERE id = ${id}");
|
||||
}
|
||||
|
||||
Future<void> updateStatusAktifKendaraan(int id, int status) async {
|
||||
final db = await dbs();
|
||||
await db.rawUpdate("UPDATE kendaraan SET status = 0");
|
||||
await db
|
||||
.rawUpdate("UPDATE kendaraan SET status = ${status} WHERE id = ${id}");
|
||||
}
|
||||
|
||||
// transaksi
|
||||
Future<List<TransaksiModel>> getAllTransaksiStatusSuccessfull() async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps =
|
||||
await db.query('transaksi', where: "status = 1");
|
||||
|
||||
return List.generate(maps.length, (index) {
|
||||
return TransaksiModel(
|
||||
id: maps[index]['id'],
|
||||
kendaraanId: maps[index]['kendaraanId'],
|
||||
bensinId: maps[index]['bensinId'],
|
||||
kodeTransaksi: maps[index]['kodeTransaksi'],
|
||||
tanggalTransaksi: maps[index]['tanggalTransaksi'] != null
|
||||
? DateTime.parse(maps[index]['tanggalTransaksi'])
|
||||
: DateTime.now(),
|
||||
waktuTransaksi: maps[index]['waktuTransaksi'] != null
|
||||
? DateTime.parse(maps[index]['waktuTransaksi'])
|
||||
: DateTime.now(),
|
||||
lokasiPertamina: maps[index]['lokasiPertamina'] != null
|
||||
? maps[index]['lokasiPertamina']
|
||||
: "-",
|
||||
totalLiter:
|
||||
maps[index]['totalLiter'] != null ? maps[index]['totalLiter'] : "0",
|
||||
hargaPerLiter: maps[index]['hargaPerLiter'] != null
|
||||
? maps[index]['hargaPerLiter']
|
||||
: 0,
|
||||
totalBayar:
|
||||
maps[index]['totalBayar'] != null ? maps[index]['totalBayar'] : 0,
|
||||
odometer:
|
||||
maps[index]['odometer'] != null ? maps[index]['odometer'] : "0",
|
||||
catatan: maps[index]['catatan'] != null ? maps[index]['catatan'] : "-",
|
||||
lat: maps[index]['latitude'] != null ? maps[index]['latitude'] : "0",
|
||||
lang: maps[index]['longitude'] != null ? maps[index]['longitude'] : "0",
|
||||
status: maps[index]['status'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<PhotoModel>> getAllPhoto(param) async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps =
|
||||
await db.query('photo', where: "transaksi_id = '${param}'");
|
||||
|
||||
return List.generate(maps.length, (index) {
|
||||
return PhotoModel(
|
||||
id: maps[index]['id'],
|
||||
transaksi_id: maps[index]['transaksi_id'],
|
||||
linkPhoto: maps[index]['linkPhoto'],
|
||||
namePhoto: maps[index]['namePhoto'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<TransaksiPerMonthModel>>
|
||||
getAllTransaksiStatusSuccessfullThisMonth(String datetime) async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
"SELECT kendaraanId, SUM(totalLiter) as totalLiter, SUM(totalBayar) as totalBayar, tanggalTransaksi FROM transaksi WHERE (strftime('%m', tanggalTransaksi) = strftime('%m', '${datetime}')) AND status = 1 GROUP BY tanggalTransaksi ORDER BY tanggalTransaksi ASC");
|
||||
|
||||
return List.generate(maps.length, (index) {
|
||||
return TransaksiPerMonthModel(
|
||||
kendaraanId: maps[index]['kendaraanId'],
|
||||
totalLiter:
|
||||
maps[index]['totalLiter'] != null ? maps[index]['totalLiter'] : 0,
|
||||
totalBayar:
|
||||
maps[index]['totalBayar'] != null ? maps[index]['totalBayar'] : 0,
|
||||
tanggalTransaksi: maps[index]['tanggalTransaksi'] != null
|
||||
? DateTime.parse(maps[index]['tanggalTransaksi'])
|
||||
: DateTime.now(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<TransaksiModel>> getAllTransaksiStatusDraft() async {
|
||||
final db = await dbs();
|
||||
|
||||
final List<Map<String, dynamic>> maps =
|
||||
await db.query('transaksi', where: "status = 0");
|
||||
|
||||
return List.generate(maps.length, (index) {
|
||||
return TransaksiModel(
|
||||
id: maps[index]['id'],
|
||||
kendaraanId: maps[index]['kendaraanId'],
|
||||
bensinId: maps[index]['bensinId'],
|
||||
kodeTransaksi: maps[index]['kodeTransaksi'],
|
||||
tanggalTransaksi: maps[index]['tanggalTransaksi'] != null
|
||||
? DateTime.parse(maps[index]['tanggalTransaksi'])
|
||||
: DateTime.now(),
|
||||
waktuTransaksi: maps[index]['waktuTransaksi'] != null
|
||||
? DateTime.parse(maps[index]['waktuTransaksi'])
|
||||
: DateTime.now(),
|
||||
lokasiPertamina: maps[index]['lokasiPertamina'] != null
|
||||
? maps[index]['lokasiPertamina']
|
||||
: "-",
|
||||
totalLiter:
|
||||
maps[index]['totalLiter'] != null ? maps[index]['totalLiter'] : "0",
|
||||
hargaPerLiter: maps[index]['hargaPerLiter'] != null
|
||||
? maps[index]['hargaPerLiter']
|
||||
: 0,
|
||||
totalBayar:
|
||||
maps[index]['totalBayar'] != null ? maps[index]['totalBayar'] : 0,
|
||||
odometer:
|
||||
maps[index]['odometer'] != null ? maps[index]['odometer'] : "0",
|
||||
catatan: maps[index]['catatan'] != null ? maps[index]['catatan'] : "-",
|
||||
lat: maps[index]['latitude'] != null ? maps[index]['latitude'] : "0",
|
||||
lang: maps[index]['longitude'] != null ? maps[index]['longitude'] : "0",
|
||||
status: maps[index]['status'],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> insertDataTransaksi(TransaksiModel model) async {
|
||||
final db = await dbs();
|
||||
|
||||
final DateFormat formatter = DateFormat('yyyy-MM-dd');
|
||||
final String formatted = formatter.format(model.tanggalTransaksi);
|
||||
final qry =
|
||||
"INSERT INTO transaksi(kendaraanId,bensinId,kodeTransaksi,tanggalTransaksi,waktuTransaksi,lokasiPertamina,totalLiter,HargaPerliter,totalBayar,odometer,catatan,latitude,longitude,status) " +
|
||||
"VALUES('${model.kendaraanId}','${model.bensinId}','${model.kodeTransaksi}','${model.tanggalTransaksi.toString()}','${model.waktuTransaksi.toString()}','${model.lokasiPertamina}','${model.totalLiter}','${model.hargaPerLiter}','${model.totalBayar}','${model.odometer}','${model.catatan}','${model.lat}','${model.lang}','${model.status}')";
|
||||
await db.rawInsert(qry);
|
||||
// print(qry);
|
||||
}
|
||||
|
||||
// photo
|
||||
Future<void> insertDataPhoto(PhotoModel model) async {
|
||||
final db = await dbs();
|
||||
await db.rawInsert(
|
||||
"INSERT INTO photo(transaksi_id,linkPhoto,namePhoto) VALUES('${model.transaksi_id}','${model.linkPhoto}','${model.namePhoto}')");
|
||||
}
|
||||
}
|
||||
28
lib/simple_bloc_observer.dart
Normal file
28
lib/simple_bloc_observer.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
|
||||
class SimpleBlocObserver extends BlocObserver {
|
||||
const SimpleBlocObserver();
|
||||
|
||||
@override
|
||||
void onEvent(Bloc<dynamic, dynamic> bloc, Object? event) {
|
||||
super.onEvent(bloc, event);
|
||||
log('${bloc.runtimeType} $event');
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(BlocBase<dynamic> bloc, Object error, StackTrace stackTrace) {
|
||||
log('${bloc.runtimeType} $error');
|
||||
super.onError(bloc, error, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
void onTransition(
|
||||
Bloc<dynamic, dynamic> bloc,
|
||||
Transition<dynamic, dynamic> transition,
|
||||
) {
|
||||
super.onTransition(bloc, transition);
|
||||
log('$transition');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user