Commit b2fb65e0 by Ramesh Babu Puvvadi

added new changes

parent f4cbf453
......@@ -37,6 +37,8 @@
<array>
<string>tel</string>
</array>
<key>NSAppleMusicUsageDescription</key>
<string>This app requires access to your music usage description</string>
<key>NSCameraUsageDescription</key>
<string>Camera access is required to capture</string>
<key>NSPhotoLibraryAddUsageDescription</key>
......
......@@ -3,8 +3,8 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
class FirebaseApi {
final _firebasemessaging = FirebaseMessaging.instance;
final _firebasemessaging = FirebaseMessaging.instance;
Future<void> initNotifications() async {
await _firebasemessaging.requestPermission();
final fcmToken = await _firebasemessaging.getToken();
......@@ -15,8 +15,11 @@ class FirebaseApi {
Future<void> handleBackgroundMessage(RemoteMessage message) async {
await Firebase.initializeApp();
//print('Title :${message.notification?.title}');
//print('Title :${message.notification?.body}');
//print('Title :${message.data}');
if (kDebugMode) {
print('Firebase title :${message.notification?.title}');
print('Firebase body :${message.notification?.body}');
print('Firebase data :${message.data}');
}
}
}
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:storemonitor/Screens/Constants.dart';
import 'package:video_player/video_player.dart';
......@@ -7,10 +8,7 @@ class VideoApp extends StatefulWidget {
final String id;
final String comment;
const VideoApp({Key? key,
required this.message,
required this.id,
required this.comment}): super(key: key);
const VideoApp({Key? key, required this.message, required this.id, required this.comment}): super(key: key);
@override
_VideoAppState createState() => _VideoAppState();
......@@ -26,39 +24,17 @@ class _VideoAppState extends State<VideoApp> {
void initState() {
super.initState();
isdata = widget.message;
//List<String> parts = isdata.split('/');
// // Find the part that contains the file ID
// String? fileId;
// for (String part in parts) {
// if (part.startsWith('d/')) {
// fileId = part.substring(2);
// print('if Condition: $fileId');
// break;
// }
// }
// if (fileId != null) {
// print('File ID: $fileId');
// } else {
// print('File ID not found in the link');
// }
String googleDriveFileUrl = isdata;
// Split the URL by '/'
List<String> urlParts = googleDriveFileUrl.split('/');
int indexOfD = urlParts.indexOf('d');
// The file ID is the part after 'd'
String fileId = urlParts.elementAt(indexOfD + 1);
//print('Testing : $urlParts[5]');
// The fileId is the first part after the last '/'
//String fileId = urlParts.last;
if (kDebugMode) {
print('File ID: $fileId');
}
videoUrl = 'https://drive.google.com/uc?export=view&id=$fileId';
if (kDebugMode) {
print('VideoLink : $videoUrl');
}
_controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl))
..initialize().then((_) {
setState(() {
......@@ -68,6 +44,7 @@ class _VideoAppState extends State<VideoApp> {
});
});
}
// void _initializeVideoPlayer() async {
// videoUrl =
// 'https://drive.google.com/uc?export=view&id=1QVUJ34BKRilfchA_0ppmM3gFIPvYIl7i';
......
......@@ -386,26 +386,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
lastError = '';
final pauseFor = int.tryParse(_pauseForController.text);
final listenFor = int.tryParse(_listenForController.text);
final options = SpeechListenOptions(
onDevice: _onDevice,
listenMode: ListenMode.confirmation,
cancelOnError: true,
partialResults: true,
autoPunctuation: true,
enableHapticFeedback: true);
// Note that `listenFor` is the maximum, not the minimum, on some
// systems recognition will be stopped before this value is reached.
// Similarly `pauseFor` is a maximum not a minimum and may be ignored
// on some devices.
final options = SpeechListenOptions(onDevice: _onDevice,listenMode: ListenMode.confirmation,cancelOnError: true, partialResults: true,autoPunctuation: true,enableHapticFeedback: true );
speech.listen(
onResult: resultListener,
onResult : resultListener,
listenFor: Duration(seconds: listenFor ?? 30),
pauseFor: Duration(seconds: pauseFor ?? 3),
localeId: _currentLocaleId,
pauseFor : Duration(seconds: pauseFor ?? 3),
localeId : _currentLocaleId,
onSoundLevelChange: soundLevelListener,
listenOptions: options,
);
setState(() {});
}
void stopListening() {
......@@ -426,21 +418,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// This callback is invoked each time new recognition results are
// available after `listen` is called.
void resultListener(SpeechRecognitionResult result) {
_logEvent(
'Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
_logEvent('Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
if (kDebugMode) {
print(
'\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
print('\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
}
setState(() async {
//lastWords = '${result.recognizedWords} - ${result.finalResult}';
lastWords = result.recognizedWords;
if (result.finalResult) {
if (kDebugMode) {
print('Final Result: $lastWords');
}
//await Future.delayed(Duration.zero);
remotevalidate(lastWords);
}
});
......@@ -449,23 +438,20 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
void soundLevelListener(double level) {
minSoundLevel = min(minSoundLevel, level);
maxSoundLevel = max(maxSoundLevel, level);
// _logEvent('sound level $level: $minSoundLevel - $maxSoundLevel ');
setState(() {
this.level = level;
});
}
void errorListener(SpeechRecognitionError error) {
_logEvent(
'Received error status: $error, listening: ${speech.isListening}');
_logEvent('Received error status: $error, listening: ${speech.isListening}');
setState(() {
lastError = '${error.errorMsg} - ${error.permanent}';
});
}
void statusListener(String status) {
_logEvent(
'Received listener status: $status, listening: ${speech.isListening}');
_logEvent('Received listener status: $status, listening: ${speech.isListening}');
setState(() {
lastStatus = status;
});
......@@ -478,6 +464,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// debugPrint(selectedVal);
//}
void _logEvent(String eventDescription) {
if (_logEvents) {
var eventTime = DateTime.now().toIso8601String();
......@@ -511,8 +498,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
if (kDebugMode) {
print('DataFetching1 $zoneValue');
}
Data dataInstance =
Data(question: lastWords, answer: zoneValue, image: 'None');
Data dataInstance = Data(question: lastWords, answer: zoneValue, image: 'None');
await ftts.setLanguage('en-IN');
//await ftts.setLanguage("en-IN");
await ftts.setSpeechRate(0.5); //speed of speech
......@@ -525,20 +511,14 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
print(await ftts.getVoices);
}
await ftts.setVoice({'name': 'Rishi', 'locale': 'en-IN'});
//await ftts.setVoice(ftts.getDefaultVoice());
//await ftts.setIosAudioCategory(
//[IosTextToSpeechAudioCategory.playAndRecord,
//IosTextToSpeechAudioCategoryOptions.defaultToSpeaker],
//);
await ftts.setIosAudioCategory(
IosTextToSpeechAudioCategory.playback,
[
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
[ IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
IosTextToSpeechAudioCategoryOptions.mixWithOthers,
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker
],
IosTextToSpeechAudioMode.defaultMode);
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker ],
IosTextToSpeechAudioMode.defaultMode
);
} else {
await ftts.setVoice({'name': ' Rishi', "locale": "en-IN"});
}
......@@ -589,7 +569,6 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
setState(() {
data = data;
});
lastWords = '';
setState(() {});
}
......
......@@ -109,6 +109,7 @@ class _CheckRegistration extends State<CheckRegistration> {
),
),
),
// ElevatedButton(
// onPressed: () {
// if (_empId.text.isNotEmpty) {
......@@ -171,11 +172,11 @@ class _CheckRegistration extends State<CheckRegistration> {
_empId.text == '';
_empId.clear();
Constants('Check Registration', 'Registered Sucessfully')
.showAlertDialog(context, false);
.showAlertDialog(context, true);
} else {
Navigator.pop(context);
Constants('Check Registration', 'Registation Failed')
.showAlertDialog(context, false);
.showAlertDialog(context, true);
file.delete();
//Navigator.of(context).pop();
}
......
import 'dart:convert';
import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
......@@ -27,23 +28,22 @@ class Home extends StatefulWidget {
}
class _Home extends State<Home> {
String? selectedRegion;
String? selectedDropdownItem = '';
String? empId;
List<String>? namesList;
List<String> storeNames = [];
List<Store> stores = [];
List<String> regions = [];
late List<GDPData> _chartData;
DateTime _selectedDate = DateTime.now();
final TextEditingController _dateTime = TextEditingController();
bool isAuthenticated = false;
bool iswarehouserelated = false;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final _controller = TextEditingController();
List<Insight>? insightslist = [];
bool isSwitched = false;
String? empId;
late List<GDPData> _chartData;
String? selectedRegion;
List<String>? namesList;
final TextEditingController _dateTime = TextEditingController();
@override
void initState() {
super.initState();
......@@ -52,15 +52,22 @@ class _Home extends State<Home> {
_selectedDate = DateTime.now();
_dateTime.text = DateFormat('yyyy/MM/dd').format(_selectedDate);
}
loadData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getString('access') == 'DIRECTOR') {
setState(() {
isAuthenticated = true;
});
} else {
setState(() {
isAuthenticated = false;
});
}
String? userId = prefs.getString("stores_list");
empId = prefs.getString('empId');
if (kDebugMode) {
print(empId);
}
final List<dynamic> jsonResponse = json.decode(userId!);
if (kDebugMode) {
print(jsonResponse);
......@@ -70,28 +77,26 @@ class _Home extends State<Home> {
print(stores);
}
// Get unique regions
if(isAuthenticated){
regions = stores.map((store) => store.region).toSet().toList();
//print(regions);
selectedRegion = regions[0];
updateStoreNames(selectedRegion!);
setState(() {});
setState((){
});
selectedDropdownItem = storeNames[0];
getupdateData(selectedDropdownItem,empId!);
}else{
updateStores();
selectedDropdownItem = storeNames[0];
getupdateData(selectedDropdownItem,empId!);
}
//namesList = (json.decode(userId!) as List<dynamic>)
//.map((map) => map['name'] as String)
//.toList();
selectedDropdownItem = storeNames[0];
getupdateData(selectedDropdownItem);
if (prefs.getString('access') == 'ADMIN' ||
prefs.getString('access') == 'MANAGER') {
setState(() {
isAuthenticated = true;
});
} else {
setState(() {
isAuthenticated = false;
});
}
if (selectedDropdownItem == 'WH KISMATPUR' ||
if(selectedDropdownItem == 'WH KISMATPUR' ||
selectedDropdownItem == 'WH BANGALORE' ||
selectedDropdownItem == 'WH VIJAYAWADA' ||
selectedDropdownItem == 'WH KANCHI') {
......@@ -102,45 +107,58 @@ class _Home extends State<Home> {
}
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
final DateTime? picked = await showDatePicker (
context: context,
initialDate: _selectedDate,
firstDate: DateTime(1900),
lastDate: DateTime.now(),
builder: (context, child) {
return Theme(
data: Theme.of(context).copyWith(
colorScheme: const ColorScheme.light(
return Theme (
data: Theme.of(context).copyWith (
colorScheme: const ColorScheme.light (
primary: Color.fromARGB(255, 125, 50, 253),
onPrimary: Colors.white,
onSurface: Colors.black,
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
textButtonTheme: TextButtonThemeData (
style: TextButton.styleFrom (
foregroundColor: const Color.fromARGB(255, 125, 50, 253),
),
),
),
child: child!,
);
});
}
);
setState(() {
_selectedDate = picked!;
_dateTime.text =
'${_selectedDate.year}/${_selectedDate.month}/${_selectedDate.day}';
getupdateData(selectedDropdownItem);
getupdateData(selectedDropdownItem,empId!);
});
}
void updateStoreNames(String region) {
storeNames = stores
storeNames = ['All', ...stores
.where((store) => store.region == region)
.map((store) => store.storename)
.toList();
.toList()];
selectedDropdownItem = storeNames[0]; // Reset the selected store
setState(() {
getupdateData(selectedDropdownItem);
getupdateData(selectedDropdownItem,empId!);
});
}
void updateStores() {
storeNames = stores.map((store) => store.storename).toList();
print('Testing Selecting Store :$storeNames');
selectedDropdownItem = storeNames[0]; // Reset the selected store
print('Testing Selecting Store :$selectedDropdownItem');
setState(() {
getupdateData(selectedDropdownItem,empId!);
});
}
......@@ -188,7 +206,6 @@ class _Home extends State<Home> {
if (kDebugMode) {
print('force press down');
}
//Navigator.pop(context);
},
child: Container(
margin: const EdgeInsets.all(12.0),
......@@ -196,7 +213,8 @@ class _Home extends State<Home> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
Visibility(visible: isAuthenticated,
child:Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
......@@ -223,6 +241,7 @@ class _Home extends State<Home> {
),
),
),
),
const SizedBox(
height: 15,
width: 1,
......@@ -240,15 +259,7 @@ class _Home extends State<Home> {
onChanged: (newValue) {
setState(() {
selectedDropdownItem = newValue;
getupdateData(selectedDropdownItem);
// if (selectedDropdownItem == 'WH KISMATPUR' ||
// selectedDropdownItem == 'WH BANGALORE' ||
// selectedDropdownItem == 'WH VIJAYAWADA' ||
// selectedDropdownItem == 'WH KANCHI') {
// iswarehouserelated = true;
// } else {
// iswarehouserelated = false;
// }
getupdateData(selectedDropdownItem,empId!);
});
},
items: storeNames.map((item) {
......@@ -271,8 +282,7 @@ class _Home extends State<Home> {
readOnly: true,
onTap: () {},
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
vertical: 15, horizontal: 10),
contentPadding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
isDense: true,
hintText: 'Select date',
border: OutlineInputBorder(
......@@ -289,9 +299,16 @@ class _Home extends State<Home> {
),
),
const SizedBox(height: 10),
const Text('AI Powered Insights',
Visibility(
visible: isAuthenticated,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'AI Powered Insights',
textAlign: TextAlign.right,
style: Constants.headerfontStyle),
style: Constants.headerfontStyle,
),
const SizedBox(
width: 0,
height: 5,
......@@ -305,7 +322,6 @@ class _Home extends State<Home> {
height: 15,
width: 1,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
child: ListView.builder(
......@@ -325,9 +341,7 @@ class _Home extends State<Home> {
builder: (BuildContext context) {
return AlertDialog(
title: const Text('View Insights'),
content: Text(
Constants.capitalizeFirstLetter(
insightslist![index].content)),
content: Text(Constants.capitalizeFirstLetter(insightslist![index].content)),
actions: <Widget>[
ToggleSwitch(
minWidth: 90.0,
......@@ -363,13 +377,12 @@ class _Home extends State<Home> {
Padding(
padding: const EdgeInsets.symmetric(
vertical: 2.0, horizontal: 2.0),
child: Row(children: [
child: Row(
children: [
SizedBox(
width: MediaQuery.of(context).size.width *
0.68,
width: MediaQuery.of(context).size.width * 0.68,
child: Text(
Constants.capitalizeFirstLetter(
insightslist![index].heading),
Constants.capitalizeFirstLetter(insightslist![index].heading),
style: Constants.headerlistitems1,
maxLines: 2,
overflow: TextOverflow.ellipsis,
......@@ -377,36 +390,17 @@ class _Home extends State<Home> {
),
),
SizedBox(
width: MediaQuery.of(context).size.width *
0.22,
width: MediaQuery.of(context).size.width * 0.22,
child: IconButton(
icon: const Icon(
false
? Icons.visibility
: Icons.visibility_off,
// You can customize the color, size, and other properties of the icon as needed
Icons.visibility_off, // or Icons.visibility
),
onPressed: () {},
),
),
]),
],
),
),
// const VerticalDivider(
// width: 1.0,
// color: Colors.white,
// ),
// SizedBox(
// width:
// MediaQuery.of(context).size.width / 0.8,
// height: 100,
// child: Text(
// insightslist![index].ins2.last,
// style: Constants.headerlistitems,
// overflow: TextOverflow.ellipsis,
// textAlign: TextAlign.left,
// //softWrap: true,
// ),
// ),
const VerticalDivider(
width: 1.0,
color: Colors.white,
......@@ -419,6 +413,10 @@ class _Home extends State<Home> {
},
),
),
],
),
),
const SizedBox(height: 10),
const Text('AI Alert Status',
textAlign: TextAlign.right,
......@@ -621,10 +619,7 @@ class _Home extends State<Home> {
margin: const EdgeInsets.only(
left: 0, top: 0, right: 0, bottom: 0),
width: MediaQuery.of(context).size.width * 0.44,
//visible: isAuthenticated,
child: Container(
//height: MediaQuery.of(context).size.width * 0.12,
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
gradient: const LinearGradient(
......@@ -632,7 +627,6 @@ class _Home extends State<Home> {
end: Alignment.bottomCenter,
colors: [
Color.fromARGB(255, 170, 133, 220),
//Color(0xFFC2185B),
Color.fromARGB(255, 201, 175, 236),
],
),
......@@ -642,15 +636,14 @@ class _Home extends State<Home> {
controller: _controller,
readOnly: true,
enabled: false,
decoration: const InputDecoration(
border: InputBorder.none),
decoration: const InputDecoration(border: InputBorder.none),
style: Constants.whitefontStyle,
textAlign: TextAlign.left,
onEditingComplete: () {
FocusScope.of(context)
.unfocus(); // remove the focus from the TextFormField
FocusScope.of(context).unfocus(); // remove the focus from the TextFormField
},
)),
),
),
),
),
],
......@@ -1148,7 +1141,7 @@ class _Home extends State<Home> {
// return chartData;
// }
Future<void> getupdateData(String? selectedDropdownItem) async {
Future<void> getupdateData(String? selectedDropdownItem, String empid) async {
showDialog(
context: context,
builder: (context) {
......@@ -1169,7 +1162,7 @@ class _Home extends State<Home> {
final String res;
//Response data;
respon = await RemoteData().geAlertSummary(selectedDropdownItem!,
'${_selectedDate.year}-$selectedmonth-$selectedday');
'${_selectedDate.year}-$selectedmonth-$selectedday',empid);
res = await RemoteData().getpendingAlerts(
selectedDropdownItem,
......@@ -1194,6 +1187,7 @@ class _Home extends State<Home> {
//_controller1.text = '\t\t Pending Videos Alerts : $pending_video_alerts';
});
if(isAuthenticated){
String insights = await RemoteData().getInsights(
selectedRegion!,
selectedDropdownItem,
......@@ -1211,6 +1205,7 @@ class _Home extends State<Home> {
insightslist = insightsList;
});
}
}
}
class MyData {
......
......@@ -50,33 +50,25 @@ class _IssueVideos extends State<IssueVideos> {
Future<void> loadData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? userId = prefs.getString("storeName");
//print(userId);
storesList = (json.decode(userId!) as List<dynamic>)
.map((map) => map['name'] as String)
.toList();
//print(storesList);
int index = storesList!.indexWhere((item) => item.contains(isMeeters));
setState(() {
selectedDropdownItem = storesList![index];
//print(selectedDropdownItem);
getData(selectedDropdownItem!);
});
}
void getData(String name) async {
if (kDebugMode) {
print("Second Class Hitting");
}
bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 29, 20, 34)));
});
return const Center(child: CircularProgressIndicator(color: Color.fromARGB(255, 29, 20, 34)));
}
);
final respon = await RemoteData().getIssueVideos(name);
Map<String, dynamic> responseMap = jsonDecode(respon);
if (kDebugMode) {
......@@ -87,13 +79,10 @@ class _IssueVideos extends State<IssueVideos> {
setState(() {
notificationslist;
});
//Navigator.of(context).pop();
} else {
//print('response $responseMap');
issue = Issue.fromJson(responseMap);
notificationslist = issue!.data;
if (notificationslist!.isNotEmpty) {
//Navigator.of(context).pop();
setState(() {
notificationslist;
});
......
......@@ -3,8 +3,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart'
show SharedPreferences;
import 'package:shared_preferences/shared_preferences.dart' show SharedPreferences;
import 'package:storemonitor/Screens/Chatboat.dart';
import 'package:storemonitor/Screens/Constants.dart';
import 'package:storemonitor/Screens/LoginPage.dart';
......@@ -39,10 +38,9 @@ class _NavBarState extends State<NavBar> {
_getSharedPreferencesValues();
isMeeters = widget.message;
names = widget.storeNames
.substring(1, widget.storeNames.length - 1) // Remove square brackets
.split(", ") // Split by comma and space
.map((store) => store.replaceAll(
RegExp(r'[^\w\s]+'), '')) // Remove non-alphanumeric characters
.substring(1, widget.storeNames.length - 1)
.split(", ")
.map((store) => store.replaceAll(RegExp(r'[^\w\s]+'), ''))
.toList();
if (kDebugMode) {
print(isMeeters);
......@@ -52,34 +50,17 @@ class _NavBarState extends State<NavBar> {
}
}
// void makePhoneCall(String phoneNumber) async {
// //FlutterPhoneDirectCaller.callNumber(phoneNumber);
// //launchUrl("tel:+99364921507");
// // final Uri phoneUri = Uri(scheme: "tel", path: phoneNumber);
// // try {
// // if (await canLaunchUrl(phoneUri)) await canLaunchUrl(phoneUri);
// // } catch (error) {
// // throw ("Cannot dial");
// // }
// final url = Uri.parse('tel:$phoneNumber');
// if (await canLaunchUrl(url)) {
// await launchUrl(url);
// } else {
// throw 'Could not launch $url';
// }
// }
void makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri(
scheme: 'tel',
path: phoneNumber,
);
if (!mounted) return; // Check if the widget is still mounted
if (!mounted) return;
await launchUrl(launchUri);
}
void requestPhoneCallPermission() async {
if (!mounted) return; // Check if the widget is still mounted
if (!mounted) return;
PermissionStatus status = await Permission.microphone.request();
if (kDebugMode) {
print('Status $status');
......@@ -88,13 +69,10 @@ class _NavBarState extends State<NavBar> {
if (status.isGranted) {
makePhoneCall('8121007327');
} else {
// Permission is denied or permanently denied, show an explanation to the user
if (status.isPermanentlyDenied) {
// Show a dialog explaining why the permission is required and how to enable it
openAppSettings();
} else {
// Permission is denied but not permanently, show a rationale to the user
if (!mounted) return; // Check if the widget is still mounted
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Phone call permission is required to make calls.'),
......@@ -112,7 +90,6 @@ class _NavBarState extends State<NavBar> {
@override
Widget build(BuildContext context) {
//_getSharedPreferencesValues();
return Drawer(
child: Column(
children: [
......@@ -121,11 +98,11 @@ class _NavBarState extends State<NavBar> {
height: 120,
margin: const EdgeInsets.only(top: 0.0),
color: const Color.fromARGB(
255, 123, 50, 254), // Set the background color
255, 123, 50, 254),
child: const Text(
'\n\n\t\t\t\tMENU', // Text content
'\n\n\t\t\t\tMENU',
style: TextStyle(
color: Colors.white, // Set the text color
color: Colors.white,
fontSize: 22.0,
fontWeight: FontWeight.w400),
textAlign: TextAlign.left,
......@@ -154,18 +131,13 @@ class _NavBarState extends State<NavBar> {
),
children: [
ListTile(
title: Text('Name : $name',
style: Constants.headerlistitems),
//onTap: () => null,
title: Text('Name : $name', style: Constants.headerlistitems),
),
const Divider(
height: 1,
),
ListTile(
//leading: const Icon(Icons.support_agent),
title: Text('Access Level : $access',
style: Constants.headerlistitems),
//onTap: () => null,
title: Text('Access Level : $access',style: Constants.headerlistitems),
),
const Divider(
height: 1,
......@@ -209,20 +181,19 @@ class _NavBarState extends State<NavBar> {
height: 1,
),
ListTile(
leading: Image.asset(
leading: Image.asset (
'assets/images/support.png',
width: 32,
height: 32,
),
title: const Text(
title: const Text (
'Raise a ticket',
style: Constants.headerlistitems,
),
onTap: () => showDialog(
onTap: () => showDialog (
context: context,
builder: (BuildContext context) {
return CustomDialog1(
message: isMeeters, names: names.toString());
return CustomDialog1(message: isMeeters, names: names.toString());
},
),
),
......@@ -230,25 +201,22 @@ class _NavBarState extends State<NavBar> {
height: 1,
),
ListTile(
leading: Image.asset(
leading: Image.asset (
'assets/images/change_password.png',
width: 32,
height: 32,
),
title: const Text(
title: const Text (
'Change Password',
style: Constants.headerlistitems,
),
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => const VideoApp()),
// );
showDialog(
showDialog (
context: context,
builder: (BuildContext context) {
return const CustomDialog();
});
}
);
},
),
const Divider(
......@@ -475,10 +443,8 @@ class _CustomDialogState extends State<CustomDialog> {
Constants('Change Password ', 'Enter Confirm Password')
.showAlertDialog(context, false);
} else {
if (_textFieldController2.text ==
_textFieldController3.text) {
bool isInternetConnected =
await Constants.checkInternetConnectivity();
if (_textFieldController2.text == _textFieldController3.text) {
bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
......@@ -509,28 +475,26 @@ class _CustomDialogState extends State<CustomDialog> {
Constants('Change Password', status)
.showAlertDialog(context, true);
}
//login(_email.text, _pass.text);
//Navigator.pop(context);
// Navigator.pop(context);
} else {
Constants.dialogMessage(context, 'Change Password',
'Check your internetconnection');
Constants.dialogMessage(context, 'Change Password','Check your internetconnection');
}
} else {
Constants.dialogMessage(context, 'Change Password',
'Must be Same New and Confirm Password');
Constants.dialogMessage(context, 'Change Password','Must be Same New and Confirm Password');
}
}
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
const Color.fromARGB(255, 62, 43, 75)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
backgroundColor: WidgetStateProperty.all<Color>(const Color.fromARGB(255, 62, 43, 75)),
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
//side: BorderSide(color: Colors.red)
))),
)
)
),
child: const Text(
'UPDATE',
style: Constants.fontStyle,
......@@ -568,7 +532,6 @@ class _customdialog1state extends State<CustomDialog1> {
final TextEditingController _textFieldController3 = TextEditingController();
String? selectedDropdownItem;
late String message;
List<String>? storesList;
@override
......@@ -780,16 +743,6 @@ class _customdialog1state extends State<CustomDialog1> {
// Show a dialog explaining why the permission is required and how to enable it
openAppSettings();
} else {
// Permission is denied b
//ut not permanently, show a rationale to the user
// var status = await Permission.sms.request();
// if (status.isGranted) {
// requestSmsPermission(message, reciepts);
// } else {
// // Permission denied
// print('SMS permission denied.');
// }
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('SMS permission is required to send messages.'),
......
......@@ -62,6 +62,7 @@ class _SignUpState extends State<SignUp> {
}
String jsonStr = json.encode(normalArray);
Navigator.pop(context);
print('User Level :$userResponse.level');
Constants.saveLoginCredentials(userResponse.empName, _email.text,
jsonStr, '', userResponse.level, true);
Navigator.pushReplacement(
......
......@@ -7,7 +7,6 @@ import 'package:http/http.dart' as http;
class RemoteData {
String BaseUrl = 'http://vaman.plutokm.com/';
String LoginUrl = 'http://vaman.plutokm.com/login_test';
//String AlertSummary = 'http://vaman.plutokm.com/alert_summary_flutter';
String AlertSummary = 'http://vaman.plutokm.com/alert_summary_flutter';
String Review = 'http://vaman.plutokm.com/alerts_new';
String EmpReport = 'http://vaman.plutokm.com/regstatusreport';
......@@ -15,17 +14,14 @@ class RemoteData {
String UploadVideo = 'http://vaman.plutokm.com/registeration_video';
String feedback = 'http://vaman.plutokm.com/api/mx_feedback_new';
String AuditData = 'http://vaman.plutokm.com/audit_page';
//String AuditData = 'http://192.168.65.111:8088/audit_page';
//String AuditupdateData = 'http://192.168.65.111:8088/audit_update';
String AuditupdateData = 'http://vaman.plutokm.com/audit_update';
String ChangePassword = 'http://vaman.plutokm.com/changePassword';
String FootFallVerify = 'http://vaman.plutokm.com/footfall_verify_flutter';
String EmployeeStatus = 'http://vaman.plutokm.com/employees_status';
String DepartmentSearch =
'http://vaman.plutokm.com/employees_status_department_instore';
String DepartmentSearch = 'http://vaman.plutokm.com/employees_status_department_instore';
String IssueVideos = 'http://vaman.plutokm.com/video_alert_page';
String UpdateIssueVideos = 'http://vaman.plutokm.com/update_video_alert';
String UpdateIssueVideos1 = 'http://vaman.plutokm.com/L2_update_video_alert';
String UpdateIssueVideos= 'http://vaman.plutokm.com/update_video_alert';
String UpdateIssueVideos1= 'http://vaman.plutokm.com/L2_update_video_alert';
String Insights = 'http://vaman.plutokm.com/get_insights';
String Type = "Content-Type";
String App_json = "application/json";
......@@ -37,26 +33,26 @@ class RemoteData {
// Stores List Request GET Method
// Login Request POST Method
Future<String> getLoginRequest(
String loginid, String pass, String token) async {
Future<String> getLoginRequest(String loginid, String pass, String token) async {
Map<String, dynamic> body = {
'login_id': loginid,
'password': pass,
'token': token,
'token' : token,
'os': Platform.isAndroid
? 'Android'
: Platform.isIOS
? 'IOS'
: 'Unknown',
};
if (kDebugMode) {
if (kDebugMode){
print(body);
}
var client = http.Client();
var res = await client.post(Uri.parse(LoginUrl),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(LoginUrl), headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) {
if (kDebugMode) {
print(res.body);
}
return res.body;
} else {
throw Exception('Status code was wrong$res.statusCode');
......@@ -64,7 +60,6 @@ class RemoteData {
}
Future<String> getVoiceResponse(File text, String? userid) async {
var header = {Type: App_json};
var res = '';
var url = '';
if (kDebugMode) {
......@@ -76,11 +71,9 @@ class RemoteData {
if (kDebugMode) {
print(url);
}
try {
final request = http.MultipartRequest('POST', Uri.parse(url));
request.files
.add(await http.MultipartFile.fromPath('image', text.path));
request.files.add(await http.MultipartFile.fromPath('image', text.path));
//request.files.add(http.MultipartFile.fromString('body_image_path', image));
//request.fields['style_code'] = stylecode;
var response = await request.send();
......@@ -96,8 +89,7 @@ class RemoteData {
}
// var response = await http.post(
// Uri.parse(url),
// headers: header,
// );
// headers: header);
// if (kDebugMode) {
// print(response.statusCode);
// }
......@@ -136,7 +128,6 @@ class RemoteData {
print(url);
}
}
var response = await http.post(
Uri.parse(url),
headers: header,
......@@ -154,11 +145,10 @@ class RemoteData {
return res;
}
Future<int> getFeedbackStatus(String notificationId, String userId,
String feed, String comments) async {
Future<int> getFeedbackStatus(String notificationId, String userId,String feed, String comments) async {
Map<String, dynamic> body = {
'NotificationID': notificationId,
'user_id': userId,
'user_id' : userId,
'verified': 'Verified',
'feedback': feed,
'comments': comments,
......@@ -182,13 +172,10 @@ class RemoteData {
//return 200;
}
Future<String?> empuploadVideo(
File imagepath, String filename, String storename) async {
try {
final request = http.MultipartRequest(
'Post', Uri.parse('http://192.168.65.111:8080/zoom'));
request.files
.add(await http.MultipartFile.fromPath('video_path', imagepath.path));
Future<String?> empuploadVideo(File imagepath, String filename, String storename) async {
try{
final request = http.MultipartRequest('Post', Uri.parse('http://192.168.65.111:8080/zoom'));
request.files.add(await http.MultipartFile.fromPath('video_path', imagepath.path));
request.fields['empid'] = '78';
request.fields['store_name'] = 'KLM AMEERPET';
request.fields['file'] = filename;
......@@ -200,11 +187,10 @@ class RemoteData {
return responseString;
}
} catch (e) {
if (kDebugMode) {
if(kDebugMode){
print("Error in upload video $e");
}
}
return null;
}
......@@ -213,7 +199,9 @@ class RemoteData {
'store': store,
'date': date,
};
if (kDebugMode) {
print(body);
}
var client = http.Client();
var res = await client.post(Uri.parse(pendingAlerts),
headers: {Type: App_json}, body: json.encode(body));
......@@ -229,9 +217,9 @@ class RemoteData {
Future<String> getInsights(String region, String store, String date) async {
Map<String, dynamic> body = {
'region': region,
'store': store,
'date': date,
'os': Platform.isAndroid
'store' : store,
'date' : date,
'os' : Platform.isAndroid
? 'Android'
: Platform.isIOS
? 'IOS'
......@@ -241,8 +229,7 @@ class RemoteData {
print(body);
}
var client = http.Client();
var res = await client.post(Uri.parse(Insights),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(Insights), headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) {
return res.body;
} else {
......@@ -252,10 +239,11 @@ class RemoteData {
// Alert Summary Post Request
Future<String> geAlertSummary(String store, String date) async {
Future<String> geAlertSummary(String store, String date, String userid) async {
Map<String, dynamic> body = {
'store': store,
'date': date,
'store' : store,
'date' : date,
'user_id' : userid,
'platform': Platform.isAndroid
? 'Android'
: Platform.isIOS
......@@ -265,6 +253,9 @@ class RemoteData {
var client = http.Client();
var res = await client.post(Uri.parse(AlertSummary),
headers: {Type: App_json}, body: json.encode(body));
if (kDebugMode) {
print(res.statusCode);
}
if (res.statusCode == 200) {
return res.body;
} else {
......@@ -272,16 +263,14 @@ class RemoteData {
}
}
Future<http.Response?> getFootFallVerify(
String store, String hours, String selectdate) async {
Map<String, dynamic> body = {
Future<http.Response?> getFootFallVerify(String store, String hours, String selectdate) async {
Map<String,dynamic> body = {
'store': store,
'hours': hours,
'date': selectdate,
'date' : selectdate,
};
var client = http.Client();
var res = await client.post(Uri.parse(FootFallVerify),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(FootFallVerify), headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) {
if (kDebugMode) {
print(res.body);
......@@ -311,8 +300,7 @@ class RemoteData {
}
}
Future<http.Response?> getDepartmentSearch(
String store, String dept, String empid) async {
Future<http.Response?> getDepartmentSearch(String store, String dept, String empid) async {
if (kDebugMode) {
print(store);
}
......@@ -322,8 +310,7 @@ class RemoteData {
'login_id': empid,
};
var client = http.Client();
var res = await client.post(Uri.parse(DepartmentSearch),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(DepartmentSearch),headers:{Type: App_json},body:json.encode(body));
if (res.statusCode == 200) {
if (kDebugMode) {
print(res.body);
......@@ -334,8 +321,7 @@ class RemoteData {
}
}
Future<String> getChangePassword(
String oldpass, String newpass, String userid) async {
Future<String> getChangePassword(String oldpass, String newpass, String userid) async {
//print(date);
Map<String, dynamic> body = {
'old_password': oldpass,
......@@ -365,7 +351,6 @@ class RemoteData {
var res = await client.post(Uri.parse(AuditData),
headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) {
//loginResponseFromJson(res as String);
if (kDebugMode) {
print(res.body);
}
......@@ -375,8 +360,7 @@ class RemoteData {
}
}
Future<String> getWeeklyUpdate(
String userid, String store, List<Map<String, dynamic>> array) async {
Future<String> getWeeklyUpdate(String userid, String store, List<Map<String, dynamic>> array) async {
Map<String, dynamic> body = {
'userid': userid,
'store': store,
......@@ -400,8 +384,7 @@ class RemoteData {
'key': path,
};
var client = http.Client();
var res = await client.post(Uri.parse(ImageUrl),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(ImageUrl), headers: {Type: App_json}, body: json.encode(body));
var jsonMap = jsonDecode(res.body);
return jsonMap['url'];
}
......@@ -411,8 +394,7 @@ class RemoteData {
'STORE': storeName,
};
var client = http.Client();
var res = await client.post(Uri.parse(EmpReport),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(EmpReport),headers: {Type: App_json}, body: json.encode(body));
if (res.statusCode == 200) {
return res.body;
} else {
......@@ -461,14 +443,13 @@ class RemoteData {
'comment': comment,
};
var client = http.Client();
var res = await client.post(Uri.parse(UpdateIssueVideos1),
headers: {Type: App_json}, body: json.encode(body));
if (kDebugMode) {
var res = await client.post(Uri.parse(UpdateIssueVideos1),headers: {Type: App_json}, body: json.encode(body));
if(kDebugMode){
print('Status Code :$res.statusCode');
}
if (res.statusCode == 200) {
if(res.statusCode == 200) {
return res.body;
} else {
}else{
throw Exception(res.statusCode);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment