second commit

This commit is contained in:
Anbarasu
2026-05-27 10:35:09 +05:30
parent c53794c04c
commit 1435ac47b0
501 changed files with 52818 additions and 0 deletions

View File

@@ -0,0 +1,137 @@
import 'dart:async';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../Data/Repository/Users/user_repository.dart';
import '../../../Helper/toast.dart';
import '../../../Model/Request/User/Updateuser/Updateuserrequest.dart';
import '../../../Model/Response/User/Updateuser/Updateuserresponse.dart';
import '../../../Model/Response/User/Usermodelresponse.dart';
import '../../../View/Authentication/Logiview.dart';
import '../../Authentication/Authcontroller.dart';
class EditProfileController extends GetxController{
TextEditingController firstNameController = TextEditingController();
TextEditingController lastNameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController contactNoController = TextEditingController();
UserDetails? userInfo;
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
UserRepository userRepository = UserRepository();
AuthController authController = Get.put(AuthController());
// Future<String?> takePhoto() async {
// final ImagePicker imagePicker = ImagePicker();
// final XFile? photo = await imagePicker.pickImage(
// source: ImageSource.camera,
// imageQuality: 50,
// );
// if (photo == null) {
// return null;
// }
// final imageBytes = await photo.readAsBytes();
// String base64Image = base64Encode(imageBytes); // Convert image to base64
// print("Base64 Image: $base64Image");
// return base64Image;
//
// }
getDetails()async{
firstNameController.text = userInfo?.firstname??'';
lastNameController.text = userInfo?.lastname??'';
emailController.text = userInfo?.authname??'';
contactNoController.text = userInfo?.contactno??'';
// update();
}
void doSomething() async {
Timer(const Duration(seconds: 1), () {
btnController.success();
profileValidation();
});
}
profileValidation ()async{
if (firstNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter Firstname");
}
else if (lastNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter Lastname");
} else if(emailController.text.isEmpty){
btnController.reset();
Toast.showToast("Please Enter Email");
}
else {
btnController.reset();
userUpdate();
}
}
userUpdate()async{
userUpdateResult(
UserUpdateRequest(
userid:userInfo?.userid??0,
authname:emailController.text,
configid: userInfo?.configid??0,
contactno:contactNoController.text,
firstname:firstNameController.text,
lastname : lastNameController.text,
email:emailController.text
)
);
}
userUpdateResult(UserUpdateRequest data)async{
UserUpdateResponse? result = await userRepository.updateUser(data);
if(result?.status == true){
AwesomeDialog(
context: Get.context!,
dialogType: DialogType.warning,
// animType: AnimType.BOTTOMSLIDE,
descTextStyle: const TextStyle(fontSize: 16,),
desc: 'Update successful, Kindly login to the app for the changes to take effect',
dismissOnTouchOutside: false,
btnOkText: 'Logout',
// btnCancelOnPress: () {
// Get.to(OrderDetails(data: data));
// },
btnOkOnPress: () async{
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.remove('token');
prefs.remove('fcmToken');
print('remove....fcmToken');
prefs.clear();
prefs.remove('userMobile');
authController.loginPhoneNumberController.clear();
// authController.passwordController.clear();
Get.offAll(()=>LoginView());
},
).show();
// Get.to(()=>HomePage(selectedIndex: 3,));
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,470 @@
import 'package:country_currency_pickers/country.dart';
import 'package:country_currency_pickers/utils/utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart' hide Response;
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../Data/Repository/Applocation/Applocationrepository.dart';
import '../../../../Data/Repository/Location/Addlocation/Addlocationrepository.dart';
import '../../../../Data/Repository/Location/Updatelocation/Updatelocationrepository.dart';
import '../../../../Globalwidgets/Googleplaces/Googleplaces.dart';
import '../../../../Helper/Constants/Apiconstants.dart';
import '../../../../Helper/Constants/Colorconstants.dart';
import '../../../../Helper/Locationservice/Locationservice.dart';
import '../../../../Helper/location_service.dart';
import '../../../../Helper/toast.dart';
import '../../../../Model/Request/Location/Addlocation/Addlocationrequest.dart';
import '../../../../Model/Request/Location/Updatelocation/Updatelocationrequest.dart';
import '../../../../Model/Response/Applocations/Applocationresponse.dart';
import '../../../../Model/Response/Location/Addlocation/Addlocationresponse.dart';
import '../../../../Model/Response/Location/Updatelocation/Updatelocationresponse.dart';
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
import '../../../../View/More/Locations/Locationview.dart';
class AddLocationController extends GetxController{
String? dialCode;
String? googleApiKey;
String? initialCountry;
String? addressField;
String? latitude;
String? longitude;
String? city;
String? state;
String? suburb;
String appLocationName = '';
String? min1Label;
String? min2Label;
String? min3Label;
String describeAddLocationUrl = '${ApiConstants.describeUrl}/9/en_us';
int deliveryMin = 30;
int cancellationSec = 20;
int appLocationId = 0;
int? moduleId;
int? locationId;
bool sec1 = true;
bool sec2 = false;
bool sec3 = false;
bool min1 = true;
bool min2 = false;
bool min3 = false;
bool editMode = false;
bool shimmer = true;
bool isEnterAddress = false;
bool progress = false;
List<AppLocationDetails> locations = [];
Position? resultPosition;
Country selectedDialogCountry = CountryPickerUtils.getCountryByIsoCode('IN');
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
TenantLocationDetails? locationInfo;
var describeValue;
final searchText = ''.obs;
final predictions = <Map<String, dynamic>>[].obs;
final selectedPlace = {}.obs;
final GooglePlacesService placesService = GooglePlacesService();
LocationService locationService = LocationService();
AppLocationRepository appLocationRepository = AppLocationRepository();
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
TextEditingController nameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController addressController = TextEditingController();
TextEditingController phoneNoController = TextEditingController();
TextEditingController postalCodeController = TextEditingController();
TextEditingController stateController = new TextEditingController();
TextEditingController cityController = new TextEditingController();
TextEditingController suburbController = new TextEditingController();
UpdateLocationRepository updateLocationRepository = UpdateLocationRepository();
AddLocationRepository addLocationRepository = AddLocationRepository();
onSearchTextChanged(String text) async {
searchText.value = text;
if (text.length > 2) {
try {
final places = await placesService.getPlacesPredictions(text);
predictions.assignAll(places);
update();
} catch (e) {
print('Error fetching predictions: $e');
}
} else {
predictions.clear();
update();
}
}
getPlaceDetails(String placeId,locationAddress) async {
try {
final details = await placesService.getPlaceDetails(placeId);
selectedPlace.value = details;
print('getPlaceDetailslatitude ${selectedPlace['geometry']['location']['lat']}');
print('getPlaceDetailslongitude ${selectedPlace['geometry']['location']['lng']}');
getAddressFromLatLng(selectedPlace['geometry']['location']['lat'],selectedPlace['geometry']['location']['lng'],locationAddress);
} catch (e) {
print('Error fetching place details: $e');
}
}
getAddressFromLatLng(double latitudes, double longitudes,locationAddress) async {
await placemarkFromCoordinates(latitudes, longitudes).then((List<Placemark> placemarks) {
Placemark place = placemarks[0];
latitude = double.parse(latitudes.toString()).toString();
longitude = double.parse(longitudes.toString()).toString();
city = '${place.locality}';
cityController.text = '${place.locality}';
stateController.text = '${place.administrativeArea}';
state = '${place.administrativeArea}';
suburbController.text = "${place.subLocality!.isNotEmpty?place.subLocality:place.street}" ;
suburb = place.subLocality!.isNotEmpty?place.subLocality:place.street;
postalCodeController.text = '${place.postalCode}';
addressController.text = locationAddress??'${place.street}, ${place.subLocality},${place.locality},${place.administrativeArea} ${place.subAdministrativeArea},${place.country},${place.postalCode}.';
isEnterAddress = true;
// address = locationAddress??'${place.street}, ${place.subLocality},${place.locality},${place.administrativeArea} ${place.subAdministrativeArea},${place.country},${place.postalCode}.';
predictions.clear();
update();
print('latitude $latitude');
print('longitude $longitude');
print('currentLocationSuburb $suburb');
print('city $city');
print('state $state');
print('postalCode ${postalCodeController.text}');
}).catchError((e) {
debugPrint(e);
});
}
getAppLocations() async{
GetAppLocations? result = await appLocationRepository.getAppLocations();
if(result?.code == 200){
locations = result?.details??[];
shimmer = false;
setValues();
update();
}
else{
Toast.showToast("${result?.message}");
}
}
setValues() {
print('setValueseditMode $editMode');
// print('addlocationnamesssssss${locationInfo['locationName']}');
if (editMode) {
locationInfo = locationInfo;
// print(locationInfo);
locationId = locationInfo?.locationid;
nameController.text = locationInfo?.locationname??'';
emailController.text = locationInfo?.locationemail??'';
addressController.text = locationInfo?.locationaddress??'';
postalCodeController.text = locationInfo?.locationpostcode??'';
suburb = locationInfo?.locationsuburb??'';
suburbController.text = locationInfo?.locationsuburb??'';
cityController.text = locationInfo?.locationcity??'';
city = locationInfo?.locationcity??'';
// print('${locationInfo['openingtime'].toString()}open time');
state = locationInfo?.locationstate??'';
stateController.text = locationInfo?.locationstate??'';
latitude = locationInfo?.locationlatitude??'';
longitude = locationInfo?.locationlong??'';
// countryCode = locationInfo['countrycode'];
phoneNoController.text = locationInfo?.locationcontact??'';
// delivery = locationInfo['delivery'];
// deliveryCharges = locationInfo['deliverycharges'] ?? [];
cancellationSec = locationInfo?.cancelsecs??0;
deliveryMin = locationInfo?.deliverymins??0;
// deliveryType = locationInfo['deliverytype'];
if (deliveryMin == 30) {
min1 = true;
min2 = false;
min3 = false;
} else if (deliveryMin == 60) {
min1 = false;
min2 = true;
min3 = false;
} else if (deliveryMin == 120) {
min1 = false;
min2 = false;
min3 = true;
}
if (cancellationSec == 20) {
sec1 = true;
sec2 = false;
sec3 = false;
} else if (cancellationSec == 30) {
sec1 = false;
sec2 = true;
sec3 = false;
} else if (cancellationSec == 40) {
sec1 = false;
sec2 = false;
sec3 = true;
}
appLocationId = locationInfo?.applocationid??0;
for (var loc in locations) {
if (loc.applocationid == appLocationId) {
appLocationName = loc.city??'';
return;
}
}
update();
}
}
describeValidation() {
if (nameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please enter location name");
} else if (emailController.text.isEmpty) {
btnController.reset();
// Toast.showToast("Please enter email");
Toast.showToast("Please enter email");
} else if (RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(emailController.text) ==
false) {
btnController.reset();
// Toast.showToast("Enter valid email");
Toast.showToast("Enter valid email");
} else if (phoneNoController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please enter contact no");
}
else if (phoneNoController.text.length !=10) {
btnController.reset();
Toast.showToast("Incorrect contact no");
}
// else if (appLocationId == 0) {
// Toast.showToast("Please select your location");
// progress = true;
// update();
//
// }
else if (addressController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please enter your location");
} else if (suburbController.text.isEmpty) {
btnController.reset();
isEnterAddress = true;
update();
Toast.showToast("Please enter suburb");
} else if (cityController.text.isEmpty) {
btnController.reset();
isEnterAddress = true;
update();
Toast.showToast("Please enter city");
}
// else if (city.toString().toLowerCase() !=
// appLocationName.toString().toLowerCase()) {
//
// setState(() {
// isEnterAddress = true;
// });
// Toast.showToast(
// "Entered address and selected location varies please enter correct location");
// }
else if (stateController.text.isEmpty) {
isEnterAddress = true;
update();
Toast.showToast("Please enter state");
} else if (postalCodeController.text.isEmpty) {
Toast.showToast("Please enter postcode");
}
// else if (deliveryMin == 0) {
// Toast.showToast("Please select delivery mins ");
// }
else {
if (editMode == false) {
progress = true;
update();
addLocation();
}
else {
updateLocation();
}
}
}
Future<void> showLoader(BuildContext context, GlobalKey key) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return SimpleDialog(
backgroundColor: Colors.white,
key: key,
// title: Text('Warning'),
children: [
Center(
child: Column(children: [
CircularProgressIndicator(color: ColorConstants.primaryColor),
SizedBox(
height: 10,
),
Text(
"Please wait....",
style: TextStyle(color: ColorConstants.primaryColor),
)
]),
)
]);
},
);
}
addLocation()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
var tenantId = prefs.getInt('tenantId');
var moduleId = prefs.getInt('moduleId');
var appLocationId = prefs.getInt('appLocationId');
var partnerId = prefs.getInt('partnerId');
addLocationResult(
AddLocation(
locationid:0,
tenantid:tenantId,
moduleid:moduleId,
applocationid:appLocationId,
locationname:"${nameController.text}",
email:"${emailController.text}",
contactno:"${phoneNoController.text}",
address:"${addressController.text}",
suburb:"${suburbController.text}",
state:"${stateController.text}",
city:"${cityController.text}",
postcode:"${postalCodeController.text}",
latitude:"$latitude",
longitude:"$longitude",
partnerid:partnerId,
opentime:"9:00",
closetime:"21:00",
deliverytype:0,
deliverymins:60,
cancelsecs:20
)
);
}
addLocationResult(AddLocation data)async{
AddLocationResponse? result = await addLocationRepository.addLocation(data);
if(result?.status == true){
locationId = 0;
nameController.clear();
emailController.clear();
addressController.clear();
postalCodeController.clear();
suburb = '';
suburbController.clear();
cityController.clear();
city = '';
state = '';
stateController.clear();
latitude = '';
longitude = '';
phoneNoController.clear();
isEnterAddress = false;
Get.to(()=>LocationView());
}
else{
Toast.showToast('Something went wrong');
}
}
updateLocation()async{
updateLocationResult(
UpdateLocation(
locationid:locationInfo?.locationid??0,
tenantid:locationInfo?.tenantid??0,
moduleid:locationInfo?.moduleid??0,
applocationid:locationInfo?.applocationid??0,
locationname:"${nameController.text}",
email:"${emailController.text}",
contactno:"${phoneNoController.text}",
address:"${addressController.text}",
suburb:"${suburbController.text}",
state:"${stateController.text}",
city:"${cityController.text}",
postcode:"${postalCodeController.text}",
latitude:"$latitude",
longitude:"$longitude",
partnerid:locationInfo?.partnerid??0,
opentime:"9:00",
closetime:"21:00",
deliverytype:0,
deliverymins:60,
cancelsecs:20
)
);
}
updateLocationResult(UpdateLocation data)async{
UpdateLocationResponse? result = await updateLocationRepository.updateLocation(data);
if(result?.status == true){
Get.to(()=>LocationView());
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,45 @@
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../Data/Repository/Location/GetLocation/getlocationrepository.dart';
import '../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
class LocationController extends GetxController{
int? tenantId;
int? moduleId;
List<TenantLocationDetails>locations = [];
bool shimmer = true;
GetLocationsRepository getLocationsRepository= GetLocationsRepository();
getLocation()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
tenantId = prefs.getInt('tenantId')??0;
moduleId = prefs.getInt('moduleId')??0;
GetLocationByTenantId? result = await getLocationsRepository.getLocationById();
getLocationByIdResult(result!);
}
getLocationByIdResult(GetLocationByTenantId data) async {
print('location result');
if (data.code == 200) {
SharedPreferences prefs = await SharedPreferences.getInstance();
locations = data.details!;
shimmer = false;
update();
print('usernamesss ${prefs.getString('userName')??''}');
print('gettenantIdinset${prefs.getInt('tenantId')!}');
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,13 @@
import 'package:get/get.dart';
class StaffDetailsController extends GetxController{
bool shimmer = true;
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,206 @@
import 'package:awesome_snackbar_content/awesome_snackbar_content.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart' hide Response;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../Data/Repository/Users/user_repository.dart';
import '../../Helper/Constants/Apiconstants.dart';
import '../../Helper/Logger.dart';
import '../../Model/Response/User/Usermodelresponse.dart';
import '../../View/Authentication/Logiview.dart';
import '../../View/More/Editprofile/Editprofileview.dart';
import '../../View/More/Faqview/faqtabs.dart';
import '../../View/More/Locations/Locationview.dart';
import '../../View/More/Notification/Notificationview.dart';
import '../../View/More/Staffs/Staffview.dart';
import '../Authentication/Authcontroller.dart';
class MoreController extends GetxController{
String? userName;
String? userContact;
String? version;
String? token;
String? dialCode;
String? imageUrl;
String? header;
String? locationLabel;
String? profileLabel;
String? FAQLabel;
String? logoutLabel;
String? actionsLabel;
String? subscriptionLabel;
String? paymentsLabel;
String? communityLabel;
String? preferencesLabel;
String? userLabel;
String? settingsLabel;
String? notificationsLabel;
int? versionValue;
int? roleId;
int? tenantId;
int? userId;
UserDetails? userInfo;
var describeValue;
String? currentVersion;
AuthController authController = Get.put(AuthController());
UserRepository userRepository = UserRepository();
String describeCompanyUrl = '${ApiConstants.describeUrl}/51/en_us';
toUser() {
if(roleId ==1) {
Get.to(() => StaffsView());
}
else{
var snackBar = SnackBar(
elevation: 0,
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.transparent,
content: AwesomeSnackbarContent(
title: 'Support',
message: 'Could not view staffs at this moment. Kindly contact app admin.',
contentType: ContentType.warning,
color: Colors.red.withAlpha(200),
),
);
ScaffoldMessenger.of(Get.context!).showSnackBar(snackBar);
}
}
toFaq() {
Get.to(()=>FaqTabs());
}
toSettings() {
}
toLocation() {
Get.to(()=>LocationView());
}
toPayment() {}
toEditProfile() {
Get.to(()=>EditProfile(data:userInfo,));
}
toNotification() {
Get.to(()=>NotificationView());
}
Future<void> confirmLogout(BuildContext context) async {
final shouldLogout = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
title: const Text(
'Confirm Logout',
style: TextStyle(fontWeight: FontWeight.bold),
),
content: const Text('Are you sure you want to log out?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
onPressed: () => Navigator.pop(context, true),
child: const Text('Logout'),
),
],
);
},
);
if (shouldLogout == true) {
await toLogin();
}
}
Future<void> toLogin() async {
print('Logging out user...');
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.clear(); // Clears all stored keys and values
authController.loginPhoneNumberController.clear();
authController.termsChecking = false;
print('Redirecting to login view...');
Get.offAll(() => LoginView());
}
getToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
token = prefs.getString('tenantFcmToken');
roleId = prefs.getInt('roleId');
versionValue = prefs.getInt('versionValue');
userName = prefs.getString('userName');
userContact = '+91${prefs.getString('tenantContactNo')}';
tenantId = prefs.getInt('tenantId');
userId = prefs.getInt('userId');
update();
get(token??'');
}
get(String token) async{
UserModelResponse? result = await userRepository.getUser(token);
if(result?.status == true){
getResults(result);
print('resultprofilecontroller${result?.details?.toJson()}');
}
}
getResults(UserModelResponse? data) {
// var data = json.encode(userData);
userInfo = data?.details;
print('userInfofullname ${userInfo?.fullname}');
userContact = '+91${data?.details!.contactno}';
userName = "${data?.details!.fullname.toString()}";
// imageUrl = "${data.details!.profileimage.toString()}";
roleId =data?.details!.roleid;
update();
if (roleId == 2) {
// getWeekdayDetails();
}
}
Future<void> getAppVersion() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version;
currentVersion = version;
prefs.setString('CurrentVersion', currentVersion!);
logger.i('Current version from main: $currentVersion');
}
@override
void onInit() {
// TODO: implement onInit
getAppVersion();
super.onInit();
}
}

View File

@@ -0,0 +1,77 @@
import 'dart:convert';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
class NotificationController extends GetxController {
RxBool isLoading = false.obs;
RxList<NotificationModel> notifications = <NotificationModel>[].obs;
Future<void> fetchNotifications() async {
isLoading.value = true;
SharedPreferences prefs = await SharedPreferences.getInstance();
// SAFE READ → Handles int or string
dynamic t = prefs.get("tenantId");
dynamic l = prefs.get("locationId");
String tenantId = t?.toString() ?? "";
String locationId = l?.toString() ?? "";
final url =
"https://jupiter.nearle.app/live/api/v1/utils/gettenantnotifications/?tenantid=$tenantId&locationid=$locationId";
try {
var response = await http.get(Uri.parse(url));
print(url);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
if (data["status"] == true) {
notifications.value = (data["details"] as List)
.map((e) => NotificationModel.fromJson(e))
.toList();
}
}
} catch (e) {
print("Notification API Error: $e");
}
isLoading.value = false;
}
@override
void onInit() {
fetchNotifications(); // auto load on page open
super.onInit();
}
}
class NotificationModel {
final int notificationid;
final String title;
final String message;
final String notificationdate;
NotificationModel({
required this.notificationid,
required this.title,
required this.message,
required this.notificationdate,
});
factory NotificationModel.fromJson(Map<String, dynamic> json) {
return NotificationModel(
notificationid: json["notificationid"],
title: json["title"] ?? "",
message: json["message"] ?? "",
notificationdate: json["notificationdate"] ?? "",
);
}
}

View File

@@ -0,0 +1,144 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../Data/Repository/Staffs/Addstaff/Addstaffrepository.dart';
import '../../../../Data/Repository/Tenantlocation/Getlocationrepository.dart';
import '../../../../Helper/toast.dart';
import '../../../../Model/Request/Staffs/Addstaffs/Addstaffsrequest.dart';
import '../../../../Model/Response/Staffs/Addstaffs/Addstaffresponse.dart';
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
import '../../../../View/More/Staffs/Staffview.dart';
class AddStaffController extends GetxController{
String? locationName;
String? locationAddress;
String? locationSuburb;
String? locationCity;
String? locationState;
String? locationPostcode;
int?tenantId;
int?appLocationId;
int?partnerId;
RxInt locationId = 0.obs;
RxBool isLocation = false.obs;
RxBool progress = false.obs;
List<TenantLocationDetails>? tenantLocation;
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
TextEditingController nameController = TextEditingController();
TextEditingController lastNameController = TextEditingController();
TextEditingController phoneNoController = TextEditingController();
TextEditingController emailController = TextEditingController();
GetLocationsRepository getLocationsRepository= GetLocationsRepository();
AddStaffRepository addStaffRepository = AddStaffRepository();
getLocation()async {
GetLocationByTenantId? result = await getLocationsRepository.getTenantLocationById();
tenantLocation = result?.details??[];
update();
print('resultgetLocation${result?.toJson()}');
}
describeValidation({bool isUpdate = false}) {
if (nameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter first name");
// AwesomeHelper.createAwesome(title: "title", message: "message");
} else if (lastNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter last name");
} else if (phoneNoController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter contact no");
} else if (emailController.text.isEmpty) {
btnController.reset();
// Toast.showToast("Please enter email");
Toast.showToast("Please Enter email");
} else if (RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(emailController.text) ==
false) {
btnController.reset();
// Toast.showToast("Enter valid email");
Toast.showToast("Please enter vaid email address");
} else if (locationId.value ==0) {
btnController.reset();
Toast.showToast("Please select location");
} else {
progress.value = true;
addStaff();
}
}
addStaff()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
tenantId = prefs.getInt('tenantId');
appLocationId = prefs.getInt('appLocationId');
partnerId = prefs.getInt('partnerId');
addStaffsResult(
CreateStaffRequest(
userid:0,
authname:"${emailController.text}",
configid: 1,
contactno:"${phoneNoController.text}",
firstname:"${nameController.text}",
lastrname:"${lastNameController.text}",
email:"${emailController.text}",
address:"$locationAddress",
suburb:"$locationSuburb",
city:"$locationCity",
state:"$locationState",
postcode:"$locationPostcode",
roleid:2,
applocationid:appLocationId,
partnerid:partnerId,
tenantid:tenantId,
locationid:locationId.value
)
);
}
addStaffsResult(CreateStaffRequest data)async{
CreateStaffResponse? result = await addStaffRepository.addStaff(data);
if(result?.status == true){
Get.to(()=>StaffsView());
nameController.clear();
lastNameController.clear();
phoneNoController.clear();
emailController.clear();
locationId.value = 0;
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,29 @@
import 'package:get/get.dart';
import '../../../Data/Repository/Staffs/Getstaffsrepository.dart';
import '../../../Model/Response/Staffs/Getstaffsresponse.dart';
class StaffsController extends GetxController{
bool shimmer = true;
List<StaffDetails>getStaff = [];
GetStaffsRepository getStaffsRepository = GetStaffsRepository();
getStaffs()async{
GetStaffsResponse? result = await getStaffsRepository.getStaffs();
if(result?.status == true){
getStaff = result?.details??[];
shimmer = false;
update();
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,145 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import '../../../../Data/Repository/Staffs/Updatestaff/Updatestaffrepository.dart';
import '../../../../Data/Repository/Tenantlocation/Getlocationrepository.dart';
import '../../../../Helper/toast.dart';
import '../../../../Model/Request/Staffs/UpdateStaff/Updatestaffrequest.dart';
import '../../../../Model/Response/Staffs/Getstaffsresponse.dart';
import '../../../../Model/Response/Staffs/Updatestaff/Updatestaffresponse.dart';
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
import '../../../../View/More/Staffs/Staffview.dart';
class UpdateStaffController extends GetxController{
String? locationName;
String? locationAddress;
String? locationSuburb;
String? locationCity;
String? locationState;
String? locationPostcode;
int?tenantId;
int?appLocationId;
int?partnerId;
int?userId;
int?roleId;
RxInt locationId = 0.obs;
RxBool isLocation = false.obs;
RxBool progress = false.obs;
StaffDetails? staffData;
List<TenantLocationDetails>? tenantLocation;
TextEditingController nameController = TextEditingController();
TextEditingController lastNameController = TextEditingController();
TextEditingController phoneNoController = TextEditingController();
TextEditingController emailController = TextEditingController();
GetLocationsRepository getLocationsRepository= GetLocationsRepository();
UpdateStaffRepository updateStaffRepository = UpdateStaffRepository();
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
setValues(){
nameController.text = staffData?.firstname??'';
lastNameController.text = staffData?.lastname??'';
phoneNoController.text = staffData?.contactno??'';
emailController.text = staffData?.email??'';
locationId.value = staffData?.locationid??0;
tenantId = staffData?.tenantid??0;
appLocationId = staffData?.applocationid??0;
partnerId = staffData?.partnerid??0;
userId = staffData?.userid??0;
roleId = staffData?.roleid??0;
update();
}
getLocation()async {
GetLocationByTenantId? result = await getLocationsRepository.getTenantLocationById();
tenantLocation = result?.details??[];
update();
print('resultgetLocation${result?.toJson()}');
}
describeValidation({bool isUpdate = false}) {
if (nameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter first name");
// AwesomeHelper.createAwesome(title: "title", message: "message");
} else if (lastNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter last name");
} else if (phoneNoController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter contact no");
} else if (emailController.text.isEmpty) {
btnController.reset();
// Toast.showToast("Please enter email");
Toast.showToast("Please Enter email");
} else if (RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(emailController.text) ==
false) {
btnController.reset();
// Toast.showToast("Enter valid email");
Toast.showToast("Please enter vaid email address");
} else if (locationId.value ==0) {
btnController.reset();
Toast.showToast("Please select location}");
} else {
progress.value = true;
updateStaff();
}
}
updateStaff()async {
updateStaffResult(
UpdateStaffRequest(
userid:userId,
authname:"${emailController.text}",
configid: 1,
contactno:"${phoneNoController.text}",
firstname:"${nameController.text}",
lastrname:"${lastNameController.text}",
email:"${emailController.text}",
address:"$locationAddress",
suburb:"$locationSuburb",
city:"$locationCity",
state:"$locationState",
postcode:"$locationPostcode",
roleid:roleId,
applocationid:appLocationId,
partnerid:partnerId,
tenantid:tenantId,
locationid:locationId.value
)
);
}
updateStaffResult(UpdateStaffRequest data)async{
UpdateStaffResponse? result = await updateStaffRepository.updateStaff(data);
if(result?.status == true){
Get.to(()=>StaffsView());
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,26 @@
import 'package:get/get.dart';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewAppController extends GetxController {
late final WebViewController webViewController;
final isLoading = true.obs;
void initializeWebViewController(String url) {
webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(Uri.parse(url));
webViewController.setNavigationDelegate(
NavigationDelegate(
onPageStarted: (_) => setLoading(true),
onPageFinished: (_) => setLoading(false),
),
);
}
void setLoading(bool value) {
isLoading.value = value;
}
}