Skip to content

Commit

Permalink
green red
Browse files Browse the repository at this point in the history
  • Loading branch information
hari01584 committed Aug 25, 2022
1 parent 339df76 commit 4c43974
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
Binary file added assets/op_darkgreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/op_lightgreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/op_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions lib/api/map_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ Future<Tuple2<Map<String, Operator>, StreamGroup<OperatorData>>> getAllOperators
print("found operator in vicinity with id! ${oper.operatorId!} with ${latlon}");

if(!(await isOperatorBookingAvaliable(oper, date, time))){
print("unavaliable operator, skipping!");
continue;
print("unavaliable operator, marking red!");
// continue;
oper.isOpFree = false;
}

operatorIdMapOp[oper.operatorId!] = oper;
Expand Down
2 changes: 2 additions & 0 deletions lib/models/operator_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Operator {
bool? isOperatorActive;
int? timestamp;

bool isOpFree = true;

Operator(
{this.operatorId,
this.centerLocation,
Expand Down
29 changes: 25 additions & 4 deletions lib/screens/operator_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ class _OperatorSelectionScreenState extends State<OperatorSelectionScreen> {

SymbolOptions createNormalSymbol(LatLng latLng) {
return SymbolOptions(
draggable: true, iconImage: "icon", iconSize: 0.5, geometry: latLng);
draggable: true, iconImage: "opgreen", iconSize: 0.5, geometry: latLng);
}

SymbolOptions createRedSymbol(LatLng latLng) {
return SymbolOptions(
draggable: true, iconImage: "opred", iconSize: 0.5, geometry: latLng);
}


SymbolOptions createHighlightSymbol(LatLng latLng) {
return SymbolOptions(
draggable: true,
iconImage: "iconhigh",
iconImage: "opgreenselec",
iconSize: 0.75,
geometry: latLng);
}
Expand All @@ -99,7 +105,14 @@ class _OperatorSelectionScreenState extends State<OperatorSelectionScreen> {
void addOrUpdateOperatorLocation(OperatorData odata) async {
LatLng latlng = LatLng(odata.loc!.lat!, odata.loc!.lon!);
print("Show op ${odata.operatorId!} with latlon ${latlng.toJson()}");
SymbolOptions symops = createNormalSymbol(latlng);
Operator operator = idToOperator[odata.operatorId!]!;

SymbolOptions symops;
if(operator.isOpFree){
symops = createNormalSymbol(latlng);
} else {
symops = createRedSymbol(latlng);
}

if (operatorMapPins.containsKey(odata.operatorId!)) {
// Update marker
Expand Down Expand Up @@ -196,6 +209,8 @@ class _OperatorSelectionScreenState extends State<OperatorSelectionScreen> {

void symbolCallback(BuildContext context, Symbol symbol) async {
if (symbol == location_pin) return;
Operator opclick = idToOperator[symbolIdToOperatorId[symbol.id]]!;
if(opclick.isOpFree == false) return;
// if last called not null then dehilight symbol
if (lastClicked != null) {
utilHighlightOperator(lastClicked!, false);
Expand All @@ -207,7 +222,6 @@ class _OperatorSelectionScreenState extends State<OperatorSelectionScreen> {
}
utilHighlightOperator(symbol, true);

Operator opclick = idToOperator[symbolIdToOperatorId[symbol.id]]!;
Provider.of<BookingProvider>(context, listen: false).setOperator(opclick);
panelController.open();
setState(() {
Expand Down Expand Up @@ -419,6 +433,13 @@ class _OperatorSelectionScreenState extends State<OperatorSelectionScreen> {
});
},
onStyleLoadedCallback: () {
addImageFromAsset(
"opgreen", "assets/op_lightgreen.png");
addImageFromAsset(
"opgreenselec", "assets/op_darkgreen.png");
addImageFromAsset(
"opred", "assets/op_red.png");

addImageFromAsset(
"icon", "assets/operator_pin_icon.png");
addImageFromAsset(
Expand Down

0 comments on commit 4c43974

Please sign in to comment.