60 lines
1.5 KiB
Dart
60 lines
1.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../constant/box_name.dart';
|
|
import '../../constant/links.dart';
|
|
import '../../main.dart';
|
|
import '../functions/crud.dart';
|
|
|
|
class PaymentController extends GetxController {
|
|
bool isloading = false;
|
|
bool isWalletCheced = false;
|
|
bool isCashCheced = false;
|
|
final formKey = GlobalKey<FormState>();
|
|
final promo = TextEditingController();
|
|
|
|
getPassengerWallet() async {
|
|
isloading = true;
|
|
update();
|
|
if (box.read(BoxName.passengerWalletDetails) == null) {
|
|
await CRUD().get(link: AppLink.getWalletByPassenger, payload: {
|
|
'passenger_id': box.read(BoxName.pasengerID)
|
|
}).then((value) {
|
|
final total = jsonDecode(value)['message'];
|
|
|
|
box.write(BoxName.passengerWalletDetails, total);
|
|
});
|
|
isloading = false;
|
|
update();
|
|
print('from empty');
|
|
print(box.read(BoxName.passengerWalletDetails));
|
|
} else {
|
|
box.read(BoxName.passengerWalletDetails);
|
|
update();
|
|
print('from full');
|
|
print(box.read(BoxName.passengerWalletDetails));
|
|
}
|
|
}
|
|
|
|
void onChangedPymentethodWallet(bool? value) {
|
|
isWalletCheced = !isWalletCheced;
|
|
isWalletCheced ? isCashCheced = false : isCashCheced = true;
|
|
update();
|
|
}
|
|
|
|
void onChangedPymentethodCash(bool? value) {
|
|
isCashCheced = !isCashCheced;
|
|
isCashCheced ? isWalletCheced = false : isWalletCheced = true;
|
|
update();
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
getPassengerWallet();
|
|
|
|
super.onInit();
|
|
}
|
|
}
|