Skip to content

Commit

Permalink
end ... 🐉
Browse files Browse the repository at this point in the history
  • Loading branch information
abdessamadpas committed Sep 14, 2023
1 parent 039107f commit 1017df3
Show file tree
Hide file tree
Showing 15 changed files with 529 additions and 114 deletions.
26 changes: 26 additions & 0 deletions lib/controllers/maintenance/gestionCarburant.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sendatrack/routers/app_pages.dart';

class GestionCarburantController extends GetxController {
RxBool isLoading = false.obs;
RxBool input = true.obs;
RxBool isOutput = false.obs;
RxList<String?> ListMatricules = <String>["wewe"].obs;
RxList<String?> ListConducteur = <String>["wewe"].obs;
RxList<String?> ListCiternes = <String>["wewe"].obs;

final TextEditingController KmPrecedentTextEditingController =
TextEditingController();
final TextEditingController QteTextEditingController =
TextEditingController();
final TextEditingController KmActuelTextEditingController =
TextEditingController();
@override
void onInit() {
super.onInit();
}
}
82 changes: 18 additions & 64 deletions lib/controllers/stock/logMovementController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import 'package:sendatrack/model/depotInfo.dart';
class LogMovementController extends GetxController {
final TextEditingController storeTextEditingController =
TextEditingController();
late List<SelectedListItem> listOfStores = <SelectedListItem>[];

RxBool tangerStore = false.obs;
RxBool casaStore = false.obs;
RxList<SelectedListItem> listOfStores = <SelectedListItem>[].obs;
RxList selectedList = [].obs;
RxString status = "".obs;
RxList<MovementGet> stockList = <MovementGet>[].obs;
RxList<MovementGet> stockListFiltered = <MovementGet>[].obs;
Expand All @@ -29,98 +27,54 @@ class LogMovementController extends GetxController {

RxBool isLoading = true.obs;
@override
void onInit() async {
listOfStores = await fetchStores();
void onInit() {
super.onInit();
fetchStores();
fetchStock();
isSavedTime.value = false;
ever(isSavedTime, (_) {
fetchStock();
});
ever(tangerStore, (_) async {
stockList.clear();
stockListFiltered.clear();
await fetchStock();
});
ever(casaStore, (_) async {
stockList.clear();
stockListFiltered.clear();
await fetchStock();
});
ever(status, (_) async {

ever(selectedList, (_) async {
stockList.clear();
stockListFiltered.clear();
await fetchStock();
});
super.onInit();
}

//!fetch stores

Future<List<SelectedListItem>> fetchStores() async {
Future<void> fetchStores() async {
List<SelectedListItem> stores = [];
listOfStores.clear();

try {
List<DepotInfo> data = await StockService.getDepotInfo("Store");
data.forEach((store) {
stores.add(SelectedListItem(
listOfStores.add(SelectedListItem(
name: store.description!,
));
});
return stores;
} catch (error) {
print('Error fetching clients: $error');
return [];
}
}

void changeStateShip(String value) {
if (_isFetching) return; // Ignore state changes when fetching data

if (value == 'tanger') {
tangerStore.value = !tangerStore.value;
casaStore.value = false;
isLoading.value = true;
} else if (value == 'casa') {
casaStore.value = !casaStore.value;
tangerStore.value = false;
isLoading.value = true;
} else {
tangerStore.value = false;
casaStore.value = false;
isLoading.value = true;
}

_isFetching = true;
//! Wait for 800 milliseconds before fetching data
Future.delayed(Duration(milliseconds: 1), () {
fetchStock().then((_) {
_isFetching = false;
});
});
}

Future<void> fetchStock() async {
if (tangerStore.value == true) {
status.value = "siege";
} else if (casaStore.value == true) {
status.value = "Dépôt Casa";
} else if (tangerStore.value == false && casaStore.value == false) {
status.value = "all";
}

isLoading.value = true;
print("selectedListttttttt $selectedList ${selectedList.length}");

List<MovementGet> data = await MovementService.GetMovements();
if (status.value == "all") {
if (selectedList.isEmpty) {
data = await data.toList();
} else if (status.value == "siege") {
data =
await data.where((element) => element.id_Store == "siege").toList();
} else if (status.value == "Dépôt Casa") {
data = await data
.where((element) => element.id_Store == "Dépôt Casa")
} else {
data = data
.where((element) => selectedList.contains(element.id_Store))
.toList();
}

//! for feltring with date
//! for feltring with date
if (startDate != null && endDate != null) {
print("filtering by date");
print("startDate $startDate");
Expand Down
6 changes: 6 additions & 0 deletions lib/routers/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../bindings/trajectDetails_binding.dart';
import '../screens/splashScreen.dart';
import '../screens/managementStockScreen/statisticsStockScreen.dart';
import '../screens/managementStockScreen/movementScreen.dart';
import '../screens/consommationScreen.dart';
import '../screens/managementStockScreen/movementLogsScreen.dart';

part 'app_routes.dart';
Expand Down Expand Up @@ -57,5 +58,10 @@ class AppPages {
page: () => Trajects(),
binding: TrajectsBinding(),
),
GetPage(
name: _Paths.consommation,
page: () => ConsommationScreen(),
// binding: TrajectsBinding(),
),
];
}
2 changes: 2 additions & 0 deletions lib/routers/app_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class Routes {
static const MOVEMENT = _Paths.movement;
static const DASHBOARDSTOCK = _Paths.dashboardStock;
static const LOGSMOVEMENT = _Paths.logsMovements;
static const CONSOMATION = _Paths.consommation;
}

abstract class _Paths {
Expand All @@ -26,4 +27,5 @@ abstract class _Paths {
static const String movement = '/movement';
static const String dashboardStock = '/dashboardStock';
static const String logsMovements = '/logsMovements';
static const String consommation = '/consommation';
}
7 changes: 7 additions & 0 deletions lib/screens/components/side_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class SideMenu extends StatelessWidget {
Get.toNamed("/dashboardStock");
},
),
DrawerListTile(
icon: TernavIcons.lightOutline.menu,
title: "Consommation Carburant",
onTap: () {
Get.toNamed("/consommation");
},
),
DrawerListTile(
icon: TernavIcons.lightOutline.settings,
title: "Maintenance",
Expand Down
34 changes: 34 additions & 0 deletions lib/screens/consommationScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import '../../../constant.dart';
import 'package:get/get.dart';
import 'package:sendatrack/widgets/consomationForm.dart';

class ConsommationScreen extends StatefulWidget {
const ConsommationScreen({super.key});

@override
State<ConsommationScreen> createState() => ConsommationScreenState();
}

class ConsommationScreenState extends State<ConsommationScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Consommation'),
),
body: Container(
child: const Center(
child: Text('Consommation'),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Get.to(() => const ConsomationForm());
},
child: const Icon(Icons.add),
),
);
}
}
Loading

0 comments on commit 1017df3

Please sign in to comment.